diff options
author | Erik Schnetter <schnetter@gmail.com> | 2013-08-20 12:59:09 -0400 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2013-08-20 12:59:09 -0400 |
commit | e00507b552f6fb4fa48e3ba083e480cb9c049694 (patch) | |
tree | 0a4173ef3d8fe68f961d2e14991b747148b2e085 /loop.cc | |
parent | e55b50d9a712087a5cfc8b7a863765d081535389 (diff) | |
download | vecmathlib-e00507b552f6fb4fa48e3ba083e480cb9c049694.zip vecmathlib-e00507b552f6fb4fa48e3ba083e480cb9c049694.tar.gz |
Use better timers for benchmarking loops
Diffstat (limited to 'loop.cc')
-rw-r--r-- | loop.cc | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -41,12 +41,11 @@ inline ticks getticks() { #if __has_builtin(__builtin_readcyclecounter) return __builtin_readcyclecounter(); -#else -# if defined __x86_64__ +#elif defined __x86_64__ ticks a, d; asm volatile("rdtsc" : "=a" (a), "=d" (d)); return a | (d << 32); -# elif defined __powerpc__ +#elif defined __powerpc__ unsigned int tbl, tbu, tbu1; do { asm volatile("mftbu %0": "=r"(tbu)); @@ -54,7 +53,13 @@ inline ticks getticks() asm volatile("mftbu %0": "=r"(tbu1)); } while (tbu != tbu1); return ((unsigned long long)tbu << 32) | tbl; -# endif +#else + timeval tv; + gettimeofday(&tv, NULL); + return 1000000ULL * tv.tv_sec + tv.tv_usec; + // timespec ts; + // clock_gettime(CLOCK_REALTIME, &ts); + // return 1000000000ULL * ts.tv_sec + ts.tv_nsec; #endif } inline double elapsed(ticks t1, ticks t0) |