diff options
author | lloyd <[email protected]> | 2010-08-13 15:13:21 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-08-13 15:13:21 +0000 |
commit | 3da3b04e1ba1577b3d0e1b4b9b3f4b24381fc433 (patch) | |
tree | 8a4b3a3b8e830ffcbd41f41859db4ab4fd972fb2 /checks/bench.cpp | |
parent | 2cae6ec17984ad016f973d5925860278e575b3f4 (diff) | |
parent | 789cee0888bbede838a2a3cf6221677c9f172872 (diff) |
propagate from branch 'net.randombit.botan' (head 0a3348f52bf558bc2282e1066c2913a72a1aeda5)
to branch 'net.randombit.botan.c++0x' (head 552c20ae8874f12da779fc25ea368e36e71cbfe8)
Diffstat (limited to 'checks/bench.cpp')
-rw-r--r-- | checks/bench.cpp | 19 |
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; |