source: src/benchmark/bench.h @ b0f601fa

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since b0f601fa was dbe7756, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

bench.h now compiles in C and C++

  • Property mode set to 100644
File size: 632 bytes
Line 
1#pragma once
2
3#ifdef __CFORALL__
4extern "C" {
5#endif
6        #include <unistd.h>                                     // sysconf
7        #include <sys/times.h>                                  // times
8        #include <time.h>
9#ifdef __CFORALL__
10}
11#endif
12
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 N
31#define N 10000000
32#endif
33
34unsigned int default_preemption() {
35        return 0;
36}
Note: See TracBrowser for help on using the repository browser.