From e292d9c1263fc74c26b26b9bd6f879ab25cc19ee Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 5 Sep 2008 12:46:18 +0000 Subject: Use the Timer class for all benchmarking --- checks/bench.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'checks/bench.cpp') diff --git a/checks/bench.cpp b/checks/bench.cpp index d3a9e06c4..f05bf8848 100644 --- a/checks/bench.cpp +++ b/checks/bench.cpp @@ -10,6 +10,7 @@ using Botan::byte; using Botan::u64bit; #include "common.h" +#include "timer.h" #include "bench.h" /* Discard output to reduce overhead */ @@ -29,26 +30,24 @@ double bench_filter(std::string name, Botan::Filter* filter, bool html, double seconds) { Botan::Pipe pipe(filter, new BitBucket); - pipe.start_msg(); - static const u32bit BUFFERSIZE = 32*1024; - byte buf[BUFFERSIZE]; + pipe.start_msg(); - rng.randomize(buf, BUFFERSIZE); + byte buf[32 * 1024]; + Timer timer(name, sizeof(buf)); - u32bit iterations = 0; - u64bit start = get_clock(), clocks_used = 0; - u64bit go_up_to = static_cast(seconds * get_ticks()); + rng.randomize(buf, sizeof(buf)); - while(clocks_used < go_up_to) + while(timer.seconds() < seconds) { - iterations++; - pipe.write(buf, BUFFERSIZE); - clocks_used = get_clock() - start; + timer.start(); + pipe.write(buf, sizeof(buf)); + timer.stop(); } - double bytes_per_sec = (static_cast(iterations) * BUFFERSIZE) / - (static_cast(clocks_used) / get_ticks()); + pipe.end_msg(); + + double bytes_per_sec = timer.events() / timer.seconds(); double mbytes_per_sec = bytes_per_sec / (1024.0 * 1024.0); std::cout.setf(std::ios::fixed, std::ios::floatfield); -- cgit v1.2.3