From 02445c9cc3a2233616f8ceed0f608453f66ad5e6 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Wed, 16 Aug 2017 23:45:29 +0200 Subject: [PATCH] Fix timing measure for multi-thread tests (as it was reported the total time consummed by all threads, not the run time). --- bench/common.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bench/common.h b/bench/common.h index aed80df2..886bd116 100644 --- a/bench/common.h +++ b/bench/common.h @@ -47,9 +47,17 @@ cputime (void) static unsigned long long cputime (void) { +#if defined(MULTI_THREAD_MEASURE) + // Multi thread + struct timeval tv; + gettimeofday (&tv, NULL); + return tv.tv_sec * 1000000ULL + tv.tv_usec; +#else + // Single thread struct rusage rus; getrusage (0, &rus); return rus.ru_utime.tv_sec * 1000000ULL + rus.ru_utime.tv_usec; +#endif } #endif