From 3879316e087089969117d32099649a5c0ed14c88 Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 22 May 2014 17:03:33 +0800 Subject: [PATCH] Add bench_duration function Conflicts: tests/bench_str.csv --- tests/bench.c | 10 +++++++--- tests/bench.h | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/bench.c b/tests/bench.c index 494cd1a..c3ef66b 100644 --- a/tests/bench.c +++ b/tests/bench.c @@ -45,12 +45,16 @@ void bench_stop(bench *b) { } double bench_iteration_speed(bench *b) { - return b->N / (b->end - b->start); + return (b->N * b->R) / (b->end - b->start); +} + +double bench_duration(bench *b) { + return (b->end - b->start); } void bench_print_summary(bench *b) { printf("%ld runs, ", b->R); printf("%ld iterations each run, ", b->N); - printf("finished in %lf seconds\n", b->end - b->start ); - printf("%.2f i/sec\n", (b->N * b->R) / (b->end - b->start) ); + printf("finished in %lf seconds\n", bench_duration(b) ); + printf("%.2f i/sec\n", bench_iteration_speed(b) ); } diff --git a/tests/bench.h b/tests/bench.h index c4f691e..0d4c898 100644 --- a/tests/bench.h +++ b/tests/bench.h @@ -35,6 +35,8 @@ double bench_iteration_speed(bench *b); void bench_print_summary(bench *b); +double bench_duration(bench *b); + #define BENCHMARK(B) \ bench B; B.N = 5000000; B.R = 3; \ bench_start(&B); \