diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-07-03 15:05:10 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-07-03 15:05:10 +0200 |
| commit | 4a16da26dacdb37b9ef8d3d11e10ecb94b0cf396 (patch) | |
| tree | 64723639df2a44c94deb26276c5793101d3b6c41 /benchmark/benchmark.h | |
| parent | 3c9efb490ccbe1b0d7768d77fcdcac012c00e8c6 (diff) | |
| download | nissy-core-4a16da26dacdb37b9ef8d3d11e10ecb94b0cf396.tar.gz nissy-core-4a16da26dacdb37b9ef8d3d11e10ecb94b0cf396.zip | |
renamed benchmarks to tools
Diffstat (limited to 'benchmark/benchmark.h')
| -rw-r--r-- | benchmark/benchmark.h | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/benchmark/benchmark.h b/benchmark/benchmark.h deleted file mode 100644 index e9361a8..0000000 --- a/benchmark/benchmark.h +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 1 | #include <stdbool.h> | ||
| 2 | #include <inttypes.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | #include <stdlib.h> | ||
| 5 | #include <time.h> | ||
| 6 | |||
| 7 | double | ||
| 8 | time_benchmark(void (*run)(void), char *name) | ||
| 9 | { | ||
| 10 | struct timespec start, end; | ||
| 11 | double tdiff, tdsec, tdnano; | ||
| 12 | |||
| 13 | printf("\n"); | ||
| 14 | fflush(stdout); | ||
| 15 | |||
| 16 | if (run == NULL) { | ||
| 17 | printf("> %s: nothing to run!\n", name); | ||
| 18 | fflush(stdout); | ||
| 19 | return -1.0; | ||
| 20 | } | ||
| 21 | |||
| 22 | printf("Benchmark: %s\n\n", name); | ||
| 23 | printf("==========\n"); | ||
| 24 | fflush(stdout); | ||
| 25 | |||
| 26 | clock_gettime(CLOCK_MONOTONIC, &start); | ||
| 27 | run(); | ||
| 28 | clock_gettime(CLOCK_MONOTONIC, &end); | ||
| 29 | |||
| 30 | tdsec = end.tv_sec - start.tv_sec; | ||
| 31 | tdnano = end.tv_nsec - start.tv_nsec; | ||
| 32 | tdiff = tdsec + 1e-9 * tdnano; | ||
| 33 | |||
| 34 | printf("==========\n"); | ||
| 35 | printf("\nTotal time: %.4fs\n", tdiff); | ||
| 36 | fflush(stdout); | ||
| 37 | |||
| 38 | return tdiff; | ||
| 39 | } | ||
