source: src/benchmark/bench.h @ 034165a

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 034165a was 034165a, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

renamed and updated benchmarks for consistency

  • Property mode set to 100644
File size: 1.0 KB
Line 
1#pragma once
2
3#if defined(__CFORALL__)
4extern "C" {
5#endif
6        #include <stdlib.h>
7        #include <unistd.h>                                     // sysconf
8        #include <sys/times.h>                                  // times
9        #include <time.h>
10#if defined(__CFORALL__)
11}
12#endif
13
14static inline unsigned long long int Time() {
15    struct timespec ts;
16    clock_gettime(
17#if defined( __linux__ )
18         CLOCK_THREAD_CPUTIME_ID,
19#elif defined( __freebsd__ )
20         CLOCK_PROF,
21#elif defined( __solaris__ )
22         CLOCK_HIGHRES,
23#else
24    #error uC++ : internal error, unsupported architecture
25#endif
26         &ts );
27    return 1000000000LL * ts.tv_sec + ts.tv_nsec;
28} // Time
29
30#ifndef BENCH_N
31#define BENCH_N 500 //10000000
32#endif
33
34#define BENCH(statement, output)                \
35        size_t n = BENCH_N;                                     \
36        if( argc > 2 ) return 1;                        \
37        if( argc == 2 ) {                                       \
38                n = atoi(argv[1]);                              \
39        }                                                                       \
40        const unsigned int NoOfTimes = n;       \
41        long long int StartTime, EndTime;       \
42        StartTime = Time();                                     \
43        statement;                                                      \
44        EndTime = Time();                                       \
45        unsigned long long int output =         \
46        ( EndTime - StartTime ) / NoOfTimes;
47
48unsigned int default_preemption() {
49        return 0;
50}
Note: See TracBrowser for help on using the repository browser.