Skip to content

Commit c0f3fe4

Browse files
author
Lealem Amedie
committed
Benchmarks: use clock_gettime() for ns resolution
1 parent 2cde843 commit c0f3fe4

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

wolfcrypt/benchmark/benchmark.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12489,16 +12489,16 @@ void bench_sphincsKeySign(byte level, byte optim)
1248912489

1249012490
double current_time(int reset)
1249112491
{
12492-
struct timeval tv;
12492+
struct timespec tv;
1249312493

1249412494
(void)reset;
1249512495

12496-
LIBCALL_CHECK_RET(gettimeofday(&tv, 0));
12496+
LIBCALL_CHECK_RET(clock_gettime(CLOCK_REALTIME, &tv));
1249712497

1249812498
#ifdef BENCH_MICROSECOND
12499-
return (double)tv.tv_sec * 1000000 + (double)tv.tv_usec;
12499+
return (double)tv.tv_sec * 1000000 + (double)tv.tv_nsec / 1000;
1250012500
#else
12501-
return (double)tv.tv_sec + (double)tv.tv_usec / 1000000;
12501+
return (double)tv.tv_sec + (double)tv.tv_nsec / 1000000000;
1250212502
#endif
1250312503
}
1250412504

0 commit comments

Comments
 (0)