diff options
author | lloyd <[email protected]> | 2008-06-28 01:12:10 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-06-28 01:12:10 +0000 |
commit | c7994492cd10fc350686afa1ac55bc6be2b18d29 (patch) | |
tree | 42a54a6266038b12ba89198086c7efb21281605b /checks/bench.cpp | |
parent | adfc19b00668f641c07c89bd08452bd3099e99d2 (diff) |
Remove most of the direct references to the global_rng() call
Diffstat (limited to 'checks/bench.cpp')
-rw-r--r-- | checks/bench.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/checks/bench.cpp b/checks/bench.cpp index 807e6db82..d3a9e06c4 100644 --- a/checks/bench.cpp +++ b/checks/bench.cpp @@ -25,6 +25,7 @@ Botan::Filter* lookup(const std::string&, namespace { double bench_filter(std::string name, Botan::Filter* filter, + Botan::RandomNumberGenerator& rng, bool html, double seconds) { Botan::Pipe pipe(filter, new BitBucket); @@ -33,7 +34,7 @@ double bench_filter(std::string name, Botan::Filter* filter, static const u32bit BUFFERSIZE = 32*1024; byte buf[BUFFERSIZE]; - global_rng().randomize(buf, BUFFERSIZE); + rng.randomize(buf, BUFFERSIZE); u32bit iterations = 0; u64bit start = get_clock(), clocks_used = 0; @@ -73,12 +74,13 @@ double bench_filter(std::string name, Botan::Filter* filter, } double bench(const std::string& name, const std::string& filtername, bool html, - double seconds, u32bit keylen, u32bit ivlen) + double seconds, u32bit keylen, u32bit ivlen, + Botan::RandomNumberGenerator& rng) { std::vector<std::string> params; Botan::SecureVector<byte> key(keylen); - global_rng().randomize(key, key.size()); + rng.randomize(key, key.size()); params.push_back(hex_encode(key, key.size())); //params.push_back(std::string(int(2*keylen), 'A')); @@ -87,13 +89,15 @@ double bench(const std::string& name, const std::string& filtername, bool html, Botan::Filter* filter = lookup(filtername, params); if(filter) - return bench_filter(name, filter, html, seconds); + return bench_filter(name, filter, rng, html, seconds); return 0; } } -void benchmark(const std::string& what, bool html, double seconds) +void benchmark(const std::string& what, + Botan::RandomNumberGenerator& rng, + bool html, double seconds) { try { if(html) @@ -120,7 +124,7 @@ void benchmark(const std::string& what, bool html, double seconds) { double speed = bench(algos[j].name, algos[j].filtername, html, seconds, algos[j].keylen, - algos[j].ivlen); + algos[j].ivlen, rng); if(speed > .00001) /* log(0) == -inf -> messed up average */ sum += std::log(speed); how_many++; @@ -158,7 +162,9 @@ void benchmark(const std::string& what, bool html, double seconds) } } -u32bit bench_algo(const std::string& name, double seconds) +u32bit bench_algo(const std::string& name, + Botan::RandomNumberGenerator& rng, + double seconds) { try { std::vector<algorithm> algos = get_algos(); @@ -168,7 +174,7 @@ u32bit bench_algo(const std::string& name, double seconds) if(algos[j].name == name) { bench(algos[j].name, algos[j].filtername, false, seconds, - algos[j].keylen, algos[j].ivlen); + algos[j].keylen, algos[j].ivlen, rng); return 1; } } |