Skip to content

Commit 9f7acea

Browse files
Update benchmark.c
1 parent eed3c9b commit 9f7acea

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

code/logic/benchmark.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ clock_t start_time;
3535
clock_t start_time;
3636
#endif
3737

38-
#if defined(__APPLE__) && !defined(CLOCK_MONOTONIC)
39-
#include <mach/mach_time.h>
40-
#endif
41-
4238
#ifndef _POSIX_C_SOURCE
4339
#define _POSIX_C_SOURCE 199309L
4440
#endif
@@ -87,9 +83,10 @@ uint64_t fossil_test_stop_benchmark(void) {
8783
}
8884

8985
void assume_duration(double expected, double actual, double unit) {
90-
clock_t end_time = clock();
91-
double elapsed_time = (double)(end_time - start_time) / ((double)CLOCKS_PER_SEC / unit);
92-
if (elapsed_time < expected) {
86+
uint64_t elapsed_time = fossil_test_stop_benchmark();
87+
double elapsed_seconds = elapsed_time / (1e9 / unit); // Convert to the desired time unit
88+
89+
if (elapsed_seconds < expected) {
9390
printf("Benchmark failed: expected %f, got %f\n", expected, actual);
9491
}
9592
}

0 commit comments

Comments
 (0)