Fix timing measure for multi-thread tests (as it was reported the total time consummed

by all threads, not the run time).
This commit is contained in:
Patrick Pelissier committed 2017-08-16 23:45:29 +02:00
1 parent ccaf183940
commit 02445c9cc3
1 file changed
+8
+8
View File
@@ -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