The unified diff between revisions [695f5995..] and [51b865be..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'checks/bench.cpp'
#
#
# patch "checks/bench.cpp"
# from [2a835fb858ad0e2047237b0354ea95f06d81dccd]
# to [194dc330534f8d0998eed9b5d92191844d30ea32]
#
============================================================
--- checks/bench.cpp 2a835fb858ad0e2047237b0354ea95f06d81dccd
+++ checks/bench.cpp 194dc330534f8d0998eed9b5d92191844d30ea32
@@ -1,15 +1,14 @@
-/* This file is in the public domain */
#include <iostream>
#include <iomanip>
-#include <ctime>
#include <cmath>
#include <string>
#include <exception>
-#include <botan/rng.h>
+#include <botan/libstate.h>
#include <botan/filters.h>
using namespace Botan_types;
+using Botan::u64bit;
#include "common.h"
@@ -32,20 +31,21 @@ double bench_filter(std::string name, Bo
static const u32bit BUFFERSIZE = 32*1024;
byte buf[BUFFERSIZE];
- Botan::Global_RNG::randomize(buf, BUFFERSIZE);
+ Botan::global_state().randomize(buf, BUFFERSIZE);
u32bit iterations = 0;
- std::clock_t start = std::clock(), clocks_used = 0;
+ u64bit start = get_clock(), clocks_used = 0;
+ u64bit go_up_to = static_cast<u64bit>(seconds * get_ticks());
- while(clocks_used < seconds * CLOCKS_PER_SEC)
+ while(clocks_used < go_up_to)
{
iterations++;
pipe.write(buf, BUFFERSIZE);
- clocks_used = std::clock() - start;
+ clocks_used = get_clock() - start;
}
- double bytes_per_sec = ((double)iterations * BUFFERSIZE) /
- ((double)clocks_used / CLOCKS_PER_SEC);
+ double bytes_per_sec = (static_cast<double>(iterations) * BUFFERSIZE) /
+ (static_cast<double>(clocks_used) / get_ticks());
double mbytes_per_sec = bytes_per_sec / (1024.0 * 1024.0);
std::cout.setf(std::ios::fixed, std::ios::floatfield);
@@ -121,7 +121,7 @@ void benchmark(const std::string& what,
if(html)
std::cout << "</TABLE>\n\n";
- double average = std::exp(sum / (double)how_many);
+ double average = std::exp(sum / static_cast<double>(how_many));
if(what == "All" && html)
std::cout << "\n<P>Overall speed average: " << average
@@ -150,7 +150,7 @@ void benchmark(const std::string& what,
}
}
-u32bit bench_algo(const std::string& name)
+u32bit bench_algo(const std::string& name, double seconds)
{
try {
std::vector<algorithm> algos = get_algos();
@@ -159,7 +159,7 @@ u32bit bench_algo(const std::string& nam
{
if(algos[j].name == name)
{
- bench(algos[j].name, algos[j].filtername, false, 3.0,
+ bench(algos[j].name, algos[j].filtername, false, seconds,
algos[j].keylen, algos[j].ivlen);
return 1;
}