source:
src/benchmark/bench.h
@
1a5ad8c
Last change on this file since 1a5ad8c was d67cdb7, checked in by , 7 years ago | |
---|---|
|
|
File size: 631 bytes |
Rev | Line | |
---|---|---|
[8cb6fcd] | 1 | #pragma once |
2 | ||
[d67cdb7] | 3 | #ifdef __CFORALL__ |
[8cb6fcd] | 4 | extern "C" { |
[d67cdb7] | 5 | #endif |
[8cb6fcd] | 6 | #include <unistd.h> // sysconf |
7 | #include <sys/times.h> // times | |
8 | #include <time.h> | |
[d67cdb7] | 9 | #ifdef __CFORALL__ |
[8cb6fcd] | 10 | } |
[d67cdb7] | 11 | #endif |
[8cb6fcd] | 12 | |
[d67cdb7] | 13 | static inline unsigned long long int Time() { |
14 | struct timespec ts; | |
[8cb6fcd] | 15 | clock_gettime( |
16 | #if defined( __linux__ ) | |
17 | CLOCK_THREAD_CPUTIME_ID, | |
18 | #elif defined( __freebsd__ ) | |
19 | CLOCK_PROF, | |
20 | #elif defined( __solaris__ ) | |
21 | CLOCK_HIGHRES, | |
22 | #else | |
23 | #error uC++ : internal error, unsupported architecture | |
24 | #endif | |
25 | &ts ); | |
26 | return 1000000000LL * ts.tv_sec + ts.tv_nsec; | |
27 | } // Time | |
28 | ||
29 | #ifndef N | |
30 | #define N 10000000 | |
[7286a40] | 31 | #endif |
32 | ||
33 | unsigned int default_preemption() { | |
34 | return 0; | |
35 | } |
Note: See TracBrowser
for help on using the repository browser.