aboutsummaryrefslogtreecommitdiffstats
path: root/checks/bench.cpp
diff options
context:
space:
mode:
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 cfb44070d..9b917c99d 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"
@@ -206,17 +209,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;