Benchmarks: use clock_gettime() for ns resolution

This commit is contained in:
Lealem Amedie
2023-11-01 17:35:15 -06:00
parent 2cde843093
commit c0f3fe4434

View File

@@ -12489,16 +12489,16 @@ void bench_sphincsKeySign(byte level, byte optim)
double current_time(int reset) double current_time(int reset)
{ {
struct timeval tv; struct timespec tv;
(void)reset; (void)reset;
LIBCALL_CHECK_RET(gettimeofday(&tv, 0)); LIBCALL_CHECK_RET(clock_gettime(CLOCK_REALTIME, &tv));
#ifdef BENCH_MICROSECOND #ifdef BENCH_MICROSECOND
return (double)tv.tv_sec * 1000000 + (double)tv.tv_usec; return (double)tv.tv_sec * 1000000 + (double)tv.tv_nsec / 1000;
#else #else
return (double)tv.tv_sec + (double)tv.tv_usec / 1000000; return (double)tv.tv_sec + (double)tv.tv_nsec / 1000000000;
#endif #endif
} }