source: src/benchmark/bench.h @ c8ad5d9

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumwith_gc
Last change on this file since c8ad5d9 was 8ad6533, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

remove cfatime.h, move itimerval constructor to "time", update concurrent examples to use Duration

  • 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//#include <bits/cfatime.h>
13#endif
14
15
16static inline unsigned long long int Time() {
17    struct timespec ts;
18    clock_gettime(
19#if defined( __linux__ )
20         CLOCK_THREAD_CPUTIME_ID,
21#elif defined( __freebsd__ )
22         CLOCK_PROF,
23#elif defined( __solaris__ )
24         CLOCK_HIGHRES,
25#else
26    #error uC++ : internal error, unsupported architecture
27#endif
28         &ts );
29    return 1000000000LL * ts.tv_sec + ts.tv_nsec;
30} // Time
31
32#ifndef BENCH_N
33#define BENCH_N 500 //10000000
34#endif
35
36#define BENCH(statement, output)                \
37        size_t n = BENCH_N;                     \
38        if( argc > 2 ) return 1;                \
39        if( argc == 2 ) {                               \
40                n = atoi(argv[1]);              \
41        }                                               \
42        long long int StartTime, EndTime;       \
43        StartTime = Time();                     \
44        statement;                                      \
45        EndTime = Time();                               \
46        unsigned long long int output =         \
47        ( EndTime - StartTime ) / n;
48
49__cfa_time_t default_preemption() {
50        return 0;
51}
Note: See TracBrowser for help on using the repository browser.