aboutsummaryrefslogtreecommitdiffstats
path: root/checks/bench.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-08-04 12:50:23 +0000
committerlloyd <[email protected]>2010-08-04 12:50:23 +0000
commite19f1554004830e99872c13b8d5fa678b93d586a (patch)
tree51ebc37d2bda7ee4ad9d16f8e0408ac9dd844dd2 /checks/bench.cpp
parent5d9eecf1646facfff9b20e9932894fce0d0ff39c (diff)
parent49ebca0d092bcb6a208604f7ac8d1b798f5170fc (diff)
propagate from branch 'net.randombit.botan' (head 717a9d103aa80e6d66c04e3a23cf173aadf56ceb)
to branch 'net.randombit.botan.c++0x' (head c9759e8ebc2f360696a11f2d00fc218d7a8bf744)
Diffstat (limited to 'checks/bench.cpp')
-rw-r--r--checks/bench.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/checks/bench.cpp b/checks/bench.cpp
index 8d35ac1c4..4f1d43a4a 100644
--- a/checks/bench.cpp
+++ b/checks/bench.cpp
@@ -14,7 +14,10 @@
#include <botan/engine.h>
#include <botan/parsing.h>
#include <botan/symkey.h>
-#include <botan/time.h>
+
+#include <chrono>
+
+typedef std::chrono::high_resolution_clock benchmark_clock;
#include "common.h"
#include "bench.h"
@@ -219,17 +222,23 @@ bool bench_algo(const std::string& algo,
Botan::Pipe pipe(filt, new Botan::BitBucket);
pipe.start_msg();
- const u64bit start = Botan::get_nanoseconds_clock();
- u64bit nanoseconds_used = 0;
+ std::chrono::nanoseconds max_time(nanoseconds_max);
+ std::chrono::nanoseconds time_used(0);
+
+ auto start = benchmark_clock::now();
+
u64bit reps = 0;
- while(nanoseconds_used < nanoseconds_max)
+ while(time_used < max_time)
{
pipe.write(&buf[0], buf.size());
++reps;
- nanoseconds_used = Botan::get_nanoseconds_clock() - start;
+ time_used = benchmark_clock::now() - start;
}
+ u64bit nanoseconds_used =
+ std::chrono::duration_cast<std::chrono::nanoseconds>(time_used).count();
+
double mbytes_per_second =
(953.67 * (buf.size() * reps)) / nanoseconds_used;