diff options
author | lloyd <[email protected]> | 2008-09-05 12:46:18 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-09-05 12:46:18 +0000 |
commit | e292d9c1263fc74c26b26b9bd6f879ab25cc19ee (patch) | |
tree | 73953a1061223fc65e9236d232caf04bbc5a1aa4 /checks/bench.cpp | |
parent | a8973ceb0c0f70e67e30b1c36e4ed833bc158445 (diff) |
Use the Timer class for all benchmarking
Diffstat (limited to 'checks/bench.cpp')
-rw-r--r-- | checks/bench.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
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<u64bit>(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<double>(iterations) * BUFFERSIZE) / - (static_cast<double>(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); |