diff options
Diffstat (limited to 'pu2/pu2.c')
| -rw-r--r-- | pu2/pu2.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -647,12 +647,20 @@ unsigned long long rdtsc(void) { #endif } +#ifndef PU2_BAD_CLOCK clock_t ntime() { struct timespec t; clock_gettime(CLOCK_MONOTONIC_RAW, &t); return t.tv_nsec + t.tv_sec * 1e9; } +#else +clock_t ntime() { + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec * 1000000000 + tv.tv_usec * 1000; +} +#endif // bench: measure using clock() double bench_cycle(int instr) { @@ -729,8 +737,14 @@ sleep_nano(int nanoseconds) { } } -[[clang::always_inline]] sleep_micro(int microseconds) { sleep_nano(microseconds * 1e3); } -[[clang::always_inline]] sleep_milli(int milliseconds) { sleep_nano(milliseconds * 1e6); } +#ifdef PU2_OLD_CLANG + #define inline() __attribute__((always_inline)) +#else + #define inline() [[clang::always_inline]] +#endif + +inline() sleep_micro(int microseconds) { sleep_nano(microseconds * 1e3); } +inline() sleep_milli(int milliseconds) { sleep_nano(milliseconds * 1e6); } // benchmark: run target for all opcodes and print summary benchmark(double (*target)(int), const char *mode_label) { |
