|
1 | | -/* arg.h -- A POSIX compliant argument parser based on plan9's arg(3) |
| 1 | +/* bench.h -- A minimal benchmarking library |
2 | 2 | * Olaf Bernstein <[email protected]> |
3 | 3 | * Distributed under the MIT license, see license at the end of the file. |
4 | 4 | * New versions available at https://github.com/camel-cdr/cauldron |
@@ -57,17 +57,17 @@ typedef struct { |
57 | 57 | BenchRecord *records; |
58 | 58 | /* temporaries */ |
59 | 59 | size_t i; |
60 | | - double ns; |
| 60 | + double secs; |
61 | 61 | } Bench; |
62 | 62 |
|
63 | 63 | static Bench benchInternal; |
64 | 64 |
|
65 | 65 | #define BENCH(title, warmup, samples) \ |
66 | 66 | for (bench_append(title), \ |
67 | 67 | benchInternal.i = (warmup) + (samples); \ |
68 | | - (benchInternal.ns = bench_gettime()), benchInternal.i--; \ |
| 68 | + (benchInternal.secs = bench_gettime()), benchInternal.i--; \ |
69 | 69 | benchInternal.i < (samples) ? \ |
70 | | - bench_update(bench_gettime()-benchInternal.ns),0 : 0) |
| 70 | + bench_update(bench_gettime()-benchInternal.secs),0 : 0) |
71 | 71 |
|
72 | 72 | static inline double |
73 | 73 | bench_gettime(void) |
@@ -143,8 +143,13 @@ bench_done(void) |
143 | 143 | putchar(' '); |
144 | 144 |
|
145 | 145 | printf("mean: %.9e, stddev: %.2e, min: %.9e \n", |
| 146 | +#ifdef BENCH_DONT_NORMALIZE |
| 147 | + b->records[i].mean, |
| 148 | + sqrt(b->records[i].M2 / b->records[i].count), |
| 149 | +#else |
146 | 150 | b->records[i].mean / minmean, |
147 | 151 | sqrt(b->records[i].M2 / b->records[i].count) / minmean, |
| 152 | +#endif |
148 | 153 | b->records[i].min); |
149 | 154 | } |
150 | 155 | b->count = 0; |
|
0 commit comments