aboutsummaryrefslogtreecommitdiff
path: root/src/bench.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/bench.h')
-rw-r--r--src/bench.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/bench.h b/src/bench.h
index db5f68cee1..3a71b4aafa 100644
--- a/src/bench.h
+++ b/src/bench.h
@@ -20,7 +20,9 @@ static double gettimedouble(void) {
void print_number(double x) {
double y = x;
int c = 0;
- if (y < 0.0) y = -y;
+ if (y < 0.0) {
+ y = -y;
+ }
while (y < 100.0) {
y *= 10.0;
c++;
@@ -35,13 +37,21 @@ void run_benchmark(char *name, void (*benchmark)(void*), void (*setup)(void*), v
double max = 0.0;
for (i = 0; i < count; i++) {
double begin, total;
- if (setup) setup(data);
+ if (setup != NULL) {
+ setup(data);
+ }
begin = gettimedouble();
benchmark(data);
total = gettimedouble() - begin;
- if (teardown) teardown(data);
- if (total < min) min = total;
- if (total > max) max = total;
+ if (teardown != NULL) {
+ teardown(data);
+ }
+ if (total < min) {
+ min = total;
+ }
+ if (total > max) {
+ max = total;
+ }
sum += total;
}
printf("%s: min ", name);