From 6ad564671027ca5caa842592ab6708003b5893ef Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 14 Aug 2009 16:21:26 +0000 Subject: Remove support for HTML benchmark output. Easier/simpler to parse the output with a script after the fact to generate such things, especially as often for HTML I want to do multiple side-by-side results. --- checks/bench.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'checks/bench.h') diff --git a/checks/bench.h b/checks/bench.h index 07d67e0d1..0cc3f46d1 100644 --- a/checks/bench.h +++ b/checks/bench.h @@ -25,10 +25,10 @@ class Benchmark_Report void benchmark(const std::string&, Botan::RandomNumberGenerator&, - bool html, double seconds); + double seconds); void bench_pk(Botan::RandomNumberGenerator&, - const std::string&, bool html, double seconds); + const std::string&, double seconds); u32bit bench_algo(const std::string&, Botan::RandomNumberGenerator&, -- cgit v1.2.3 From 6cb4b06db7855fa8bec60b2965fe34fb01e5896c Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 24 Sep 2009 16:44:26 +0000 Subject: Modify the self test program to use the builtin runtime benchmarking goop. Features dropped: RNG benchmarking, the --bench-type option. New feature: Anything the library understands can be benchmarked using --bench-algo. Use 3DES and Serpent for mode benchmarking along with AES-128. --- checks/algos.cpp | 107 ------------------ checks/bench.cpp | 314 ++++++++++++++++++++++++++++++++-------------------- checks/bench.h | 33 ++---- checks/check.cpp | 32 +----- checks/clock.cpp | 82 -------------- checks/common.h | 15 +-- checks/pk_bench.cpp | 14 +++ checks/timer.cpp | 7 ++ 8 files changed, 223 insertions(+), 381 deletions(-) delete mode 100644 checks/algos.cpp delete mode 100644 checks/clock.cpp (limited to 'checks/bench.h') diff --git a/checks/algos.cpp b/checks/algos.cpp deleted file mode 100644 index fd75bc463..000000000 --- a/checks/algos.cpp +++ /dev/null @@ -1,107 +0,0 @@ - -#include -#include -using namespace Botan; - -#include "common.h" - -std::vector get_algos() - { - std::vector algos; - - algos.push_back(algorithm("Block Cipher", "AES-128", "AES-128/ECB", 16)); - algos.push_back(algorithm("Block Cipher", "AES-192", "AES-192/ECB", 24)); - algos.push_back(algorithm("Block Cipher", "AES-256", "AES-256/ECB", 32)); - algos.push_back(algorithm("Block Cipher", "Blowfish", "Blowfish/ECB", 32)); - algos.push_back(algorithm("Block Cipher", "CAST-128", "CAST-128/ECB", 16)); - algos.push_back(algorithm("Block Cipher", "CAST-256", "CAST-256/ECB", 32)); - algos.push_back(algorithm("Block Cipher", "DES", "DES/ECB", 8)); - algos.push_back(algorithm("Block Cipher", "DESX", "DESX/ECB", 24)); - algos.push_back(algorithm("Block Cipher", "TripleDES", - "TripleDES/ECB", 24)); - algos.push_back(algorithm("Block Cipher", "GOST", "GOST/ECB", 32)); - algos.push_back(algorithm("Block Cipher", "IDEA", "IDEA/ECB", 16)); - algos.push_back(algorithm("Block Cipher", "KASUMI", "KASUMI/ECB", 16)); - - algos.push_back(algorithm("Block Cipher", - "Lion", - "Lion(SHA-256,Turing,8192)/ECB", 32)); - - algos.push_back(algorithm("Block Cipher", "Luby-Rackoff(SHA-512)", - "Luby-Rackoff(SHA-512)/ECB", 16)); - - algos.push_back(algorithm("Block Cipher", "MARS", "MARS/ECB", 32)); - algos.push_back(algorithm("Block Cipher", "MISTY1", "MISTY1/ECB", 16)); - algos.push_back(algorithm("Block Cipher", "Noekeon", "Noekeon/ECB", 16)); - algos.push_back(algorithm("Block Cipher", "RC2", "RC2/ECB", 16)); - algos.push_back(algorithm("Block Cipher", "RC5(12)", "RC5(12)/ECB", 16)); - algos.push_back(algorithm("Block Cipher", "RC5(16)", "RC5(16)/ECB", 16)); - algos.push_back(algorithm("Block Cipher", "RC6", "RC6/ECB", 32)); - algos.push_back(algorithm("Block Cipher", "SAFER-SK(10)", - "SAFER-SK(10)/ECB", 16)); - algos.push_back(algorithm("Block Cipher", "SEED", "SEED/ECB", 16)); - algos.push_back(algorithm("Block Cipher", "Serpent", "Serpent/ECB", 32)); - algos.push_back(algorithm("Block Cipher", "Skipjack", "Skipjack/ECB", 10)); - algos.push_back(algorithm("Block Cipher", "Square", "Square/ECB", 16)); - algos.push_back(algorithm("Block Cipher", "TEA", "TEA/ECB", 16)); - algos.push_back(algorithm("Block Cipher", "Twofish", "Twofish/ECB", 32)); - algos.push_back(algorithm("Block Cipher", "XTEA", "XTEA/ECB", 16)); - - algos.push_back(algorithm("Cipher Mode", "DES/CBC/PKCS7", 8, 8)); - algos.push_back(algorithm("Cipher Mode", "TripleDES/CBC/PKCS7", 24, 8)); - - algos.push_back(algorithm("Cipher Mode", "AES-128/CBC/PKCS7", 16, 16)); - algos.push_back(algorithm("Cipher Mode", "AES-128/CBC/CTS", 16, 16)); - algos.push_back(algorithm("Cipher Mode", "AES-128/CFB(128)", 16, 16)); - algos.push_back(algorithm("Cipher Mode", "AES-128/CFB(64)", 16, 16)); - algos.push_back(algorithm("Cipher Mode", "AES-128/CFB(32)", 16, 16)); - algos.push_back(algorithm("Cipher Mode", "AES-128/CFB(16)", 16, 16)); - algos.push_back(algorithm("Cipher Mode", "AES-128/CFB(8)", 16, 16)); - algos.push_back(algorithm("Cipher Mode", "AES-128/OFB", 16, 16)); - algos.push_back(algorithm("Cipher Mode", "AES-128/CTR", - "AES-128/CTR-BE", 16, 16)); - algos.push_back(algorithm("Cipher Mode", "AES-128/EAX", 16, 16)); - algos.push_back(algorithm("Cipher Mode", "AES-128/XTS", 32, 16)); - algos.push_back(algorithm("Cipher Mode", "Serpent/CTR", - "Serpent/CTR-BE", 32, 16)); - - algos.push_back(algorithm("Stream Cipher", "ARC4", 16)); - algos.push_back(algorithm("Stream Cipher", "Salsa20", 32)); - algos.push_back(algorithm("Stream Cipher", "Turing", 32)); - algos.push_back(algorithm("Stream Cipher", "WiderWake4+1", - "WiderWake4+1-BE", 16, 8)); - - algos.push_back(algorithm("Hash", "Adler32")); - algos.push_back(algorithm("Hash", "CRC24")); - algos.push_back(algorithm("Hash", "CRC32")); - algos.push_back(algorithm("Hash", "BMW-512")); - algos.push_back(algorithm("Hash", "FORK-256")); - algos.push_back(algorithm("Hash", "GOST-34.11")); - algos.push_back(algorithm("Hash", "HAS-160")); - algos.push_back(algorithm("Hash", "MD2")); - algos.push_back(algorithm("Hash", "MD4")); - algos.push_back(algorithm("Hash", "MD5")); - algos.push_back(algorithm("Hash", "RIPEMD-128")); - algos.push_back(algorithm("Hash", "RIPEMD-160")); - algos.push_back(algorithm("Hash", "SHA-160")); - algos.push_back(algorithm("Hash", "SHA-256")); - algos.push_back(algorithm("Hash", "SHA-384")); - algos.push_back(algorithm("Hash", "SHA-512")); - algos.push_back(algorithm("Hash", "Skein-512")); - algos.push_back(algorithm("Hash", "Tiger")); - algos.push_back(algorithm("Hash", "Whirlpool")); - - algos.push_back(algorithm("MAC", "CMAC(AES-128)", 16)); - algos.push_back(algorithm("MAC", "HMAC(SHA-1)", 16)); - algos.push_back(algorithm("MAC", "X9.19-MAC", 16)); - - algos.push_back(algorithm("RNG", "AutoSeeded", 4096)); - algos.push_back(algorithm("RNG", "HMAC_RNG", 4096)); - algos.push_back(algorithm("RNG", "Randpool", 4096)); - algos.push_back(algorithm("RNG", "X9.31-RNG", 4096)); - - algos.push_back(algorithm("Codec", "Base64_Encode")); - algos.push_back(algorithm("Codec", "Base64_Decode")); - - return algos; - } diff --git a/checks/bench.cpp b/checks/bench.cpp index 1610bed1e..d0fff1114 100644 --- a/checks/bench.cpp +++ b/checks/bench.cpp @@ -1,162 +1,230 @@ #include #include -#include -#include -#include +#include +#include +#include #include -using Botan::byte; -using Botan::u64bit; +#include +#include +#include #include "common.h" -#include "timer.h" #include "bench.h" -/* Discard output to reduce overhead */ -struct BitBucket : public Botan::Filter +namespace { + +const std::string algos[] = { + + /* Block ciphers */ + "AES-128", + "AES-192", + "AES-256", + "Blowfish", + "CAST-128", + "CAST-256", + "DES", + "DESX", + "GOST", + "IDEA", + "KASUMI", + "Lion(SHA-256,Turing,8192)", + "Luby-Rackoff(SHA-512)", + "MARS", + "MISTY1", + "Noekeon", + "RC2", + "RC5(12)", + "RC5(16)", + "RC6", + "SAFER-SK(10)", + "SEED", + "Serpent", + "Skipjack", + "Square", + "TEA", + "TripleDES", + "Twofish", + "XTEA", + + /* Cipher modes */ + "TripleDES/CBC/PKCS7", + "TripleDES/CBC/CTS", + "TripleDES/CTR-BE", + "TripleDES/EAX", + "TripleDES/OFB", + "TripleDES/CFB(64)", + "TripleDES/CFB(32)", + "TripleDES/CFB(16)", + "TripleDES/CFB(8)", + + "AES-128/CBC/PKCS7", + "AES-128/CBC/CTS", + "AES-128/CTR-BE", + "AES-128/EAX", + "AES-128/OFB", + "AES-128/XTS", + "AES-128/CFB(128)", + "AES-128/CFB(64)", + "AES-128/CFB(32)", + "AES-128/CFB(16)", + "AES-128/CFB(8)", + + "Serpent/CBC/PKCS7", + "Serpent/CBC/CTS", + "Serpent/CTR-BE", + "Serpent/EAX", + "Serpent/OFB", + "Serpent/XTS", + "Serpent/CFB(128)", + "Serpent/CFB(64)", + "Serpent/CFB(32)", + "Serpent/CFB(16)", + "Serpent/CFB(8)", + + /* Stream ciphers */ + "ARC4", + "Salsa20", + "Turing", + "WiderWake4+1-BE", + + /* Checksums */ + "Adler32", + "CRC24", + "CRC32", + + /* Hashes */ + "BMW-512", + "FORK-256", + "GOST-34.11", + "HAS-160", + "MD2", + "MD4", + "MD5", + "RIPEMD-128", + "RIPEMD-160", + "SHA-160", + "SHA-256", + "SHA-384", + "SHA-512", + "Skein-512", + "Tiger", + "Whirlpool", + + /* MACs */ + "CMAC(AES-128)", + "HMAC(SHA-1)", + "X9.19-MAC", + "", +}; + +void report_results(const std::string& algo, + const std::map& speeds) { - void write(const byte[], u32bit) {} - }; + // invert, showing fastest impl first + std::map results; -Botan::Filter* lookup(const std::string&, - const std::vector&, - const std::string& = "All"); + for(std::map::const_iterator i = speeds.begin(); + i != speeds.end(); ++i) + { + // Speeds might collide, tweak slightly to handle this + if(results[i->second] == "") + results[i->second] = i->first; + else + results[i->second - .01] = i->first; + } -namespace { + std::cout << algo; -double bench_filter(std::string name, Botan::Filter* filter, - Botan::RandomNumberGenerator& rng, - double seconds) - { - Botan::Pipe pipe(filter, new BitBucket); + for(std::map::const_reverse_iterator i = results.rbegin(); + i != results.rend(); ++i) + { + std::cout << " [" << i->second << "] " + << std::fixed << std::setprecision(2) << i->first; + } + std::cout << "\n"; + } + +} - std::vector buf(128 * 1024); - rng.randomize(&buf[0], buf.size()); +bool bench_algo(const std::string& algo, + Botan::RandomNumberGenerator& rng, + double seconds) + { + Botan::Default_Benchmark_Timer timer; + Botan::Algorithm_Factory& af = Botan::global_state().algorithm_factory(); - pipe.start_msg(); + u32bit milliseconds = static_cast(seconds * 1000); - Timer timer(name, buf.size()); + std::map speeds = + algorithm_benchmark(algo, milliseconds, timer, rng, af); - while(timer.seconds() < seconds) + if(speeds.empty()) // maybe a cipher mode, then? { - timer.start(); - pipe.write(&buf[0], buf.size()); - timer.stop(); - } + Botan::Algorithm_Factory::Engine_Iterator i(af); - pipe.end_msg(); + std::vector algo_parts = Botan::split_on(algo, '/'); - double bytes_per_sec = timer.events() / timer.seconds(); - double mbytes_per_sec = bytes_per_sec / (1024.0 * 1024.0); + if(algo_parts.empty()) + return false; - std::cout.setf(std::ios::fixed, std::ios::floatfield); - std::cout.precision(2); - std::cout << name << " " << std::string(25 - name.length(), ' '); - std::cout.width(6); - std::cout << mbytes_per_sec << " MiB/sec" << std::endl; - return (mbytes_per_sec); - } + std::string cipher = algo_parts[0]; -double bench(const std::string& name, const std::string& filtername, - double seconds, u32bit keylen, u32bit ivlen, - Botan::RandomNumberGenerator& rng) - { - std::vector params; + u32bit cipher_keylen = + af.prototype_block_cipher(cipher)->MAXIMUM_KEYLENGTH; + u32bit cipher_ivlen = + af.prototype_block_cipher(cipher)->BLOCK_SIZE; - Botan::SecureVector key(keylen); - rng.randomize(key, key.size()); - params.push_back(hex_encode(key, key.size())); + if(algo_parts[1] == "XTS") + cipher_keylen *= 2; // hack! - //params.push_back(std::string(int(2*keylen), 'A')); - params.push_back(std::string(int(2* ivlen), 'A')); + std::vector buf(16 * 1024); + rng.randomize(&buf[0], buf.size()); - Botan::Filter* filter = lookup(filtername, params); + while(Botan::Engine* engine = i.next()) + { + u64bit nanoseconds_max = static_cast(seconds * 1000000000.0); - if(filter) - return bench_filter(name, filter, rng, seconds); - return 0; - } + Botan::Keyed_Filter* filt = + engine->get_cipher(algo, Botan::ENCRYPTION, af); -} + if(!filt) + continue; -void benchmark(const std::string& what, - Botan::RandomNumberGenerator& rng, - double seconds) - { - try { - double sum = 0; - u32bit how_many = 0; + filt->set_key(Botan::SymmetricKey(&buf[0], cipher_keylen)); + filt->set_iv(Botan::InitializationVector(&buf[0], cipher_ivlen)); - std::vector algos = get_algos(); + Botan::Pipe pipe(filt, new Botan::BitBucket); + pipe.start_msg(); - for(u32bit j = 0; j != algos.size(); j++) - if(what == "All" || what == algos[j].type) + const u64bit start = timer.clock(); + u64bit nanoseconds_used = 0; + u64bit reps = 0; + + while(nanoseconds_used < nanoseconds_max) { - double speed = bench(algos[j].name, algos[j].filtername, - seconds, algos[j].keylen, - algos[j].ivlen, rng); - if(speed > .00001) /* log(0) == -inf -> messed up average */ - sum += std::log(speed); - how_many++; + pipe.write(&buf[0], buf.size()); + ++reps; + nanoseconds_used = timer.clock() - start; } - double average = std::exp(sum / static_cast(how_many)); + double mbytes_per_second = + (953.67 * (buf.size() * reps)) / nanoseconds_used; - if(what == "All") - std::cout << "\nOverall speed average: " << average - << std::endl; - } - catch(Botan::Exception& e) - { - std::cout << "Botan exception caught: " << e.what() << std::endl; - return; - } - catch(std::exception& e) - { - std::cout << "Standard library exception caught: " << e.what() - << std::endl; - return; - } - catch(...) - { - std::cout << "Unknown exception caught." << std::endl; - return; + speeds[engine->provider_name()] = mbytes_per_second; + } } + + if(!speeds.empty()) + report_results(algo, speeds); + + return !speeds.empty(); } -u32bit bench_algo(const std::string& name, - Botan::RandomNumberGenerator& rng, - double seconds) +void benchmark(Botan::RandomNumberGenerator& rng, + double seconds) { - try { - std::vector algos = get_algos(); - - for(u32bit j = 0; j != algos.size(); j++) - { - if(algos[j].name == name) - { - bench(algos[j].name, algos[j].filtername, seconds, - algos[j].keylen, algos[j].ivlen, rng); - return 1; - } - } - return 0; - } - catch(Botan::Exception& e) - { - std::cout << "Botan exception caught: " << e.what() << std::endl; - return 0; - } - catch(std::exception& e) - { - std::cout << "Standard library exception caught: " << e.what() - << std::endl; - return 0; - } - catch(...) - { - std::cout << "Unknown exception caught." << std::endl; - return 0; - } + for(u32bit i = 0; algos[i] != ""; ++i) + bench_algo(algos[i], rng, seconds); } diff --git a/checks/bench.h b/checks/bench.h index 0cc3f46d1..835db0101 100644 --- a/checks/bench.h +++ b/checks/bench.h @@ -1,37 +1,18 @@ -#ifndef BOTAN_BENCHMARCH_H__ -#define BOTAN_BENCHMARCH_H__ +#ifndef BOTAN_CHECK_BENCHMARK_H__ +#define BOTAN_CHECK_BENCHMARK_H__ #include #include -#include -#include -#include "timer.h" -#include - -class Benchmark_Report - { - public: - void report(const std::string& name, Timer timer) - { - std::cout << name << " " << timer << std::endl; - data[name].insert(timer); - } - - private: - std::map > data; - }; - - -void benchmark(const std::string&, Botan::RandomNumberGenerator&, +void benchmark(Botan::RandomNumberGenerator& rng, double seconds); +bool bench_algo(const std::string& algo_name, + Botan::RandomNumberGenerator& rng, + double seconds); + void bench_pk(Botan::RandomNumberGenerator&, const std::string&, double seconds); -u32bit bench_algo(const std::string&, - Botan::RandomNumberGenerator&, - double); - #endif diff --git a/checks/check.cpp b/checks/check.cpp index 30ee90d98..b460d34f7 100644 --- a/checks/check.cpp +++ b/checks/check.cpp @@ -111,8 +111,6 @@ int main(int argc, char* argv[]) << "Options:\n" << " --test || --validate: Run tests (do this at least once)\n" << " --benchmark: Benchmark everything\n" - << " --bench-type={block,mode,stream,hash,mac,rng,pk}:\n" - << " Benchmark only algorithms of a particular type\n" << " --seconds=n: Benchmark for n seconds\n" << " --init=: Pass to the library\n" << " --help: Print this message\n"; @@ -127,7 +125,7 @@ int main(int argc, char* argv[]) opts.is_set("benchmark") || opts.is_set("bench-type")) { - double seconds = 5; + double seconds = 2; if(opts.is_set("seconds")) { @@ -141,7 +139,7 @@ int main(int argc, char* argv[]) if(opts.is_set("benchmark")) { - benchmark("All", rng, seconds); + benchmark(rng, seconds); } else if(opts.is_set("bench-algo")) { @@ -151,34 +149,10 @@ int main(int argc, char* argv[]) for(u32bit j = 0; j != algs.size(); j++) { const std::string alg = algs[j]; - u32bit found = bench_algo(alg, rng, seconds); - if(!found) // maybe it's a PK algorithm + if(!bench_algo(alg, rng, seconds)) // maybe it's a PK algorithm bench_pk(rng, alg, seconds); } } - else if(opts.is_set("bench-type")) - { - const std::string type = opts.value("bench-type"); - - if(type == "all") - benchmark("All", rng, seconds); - else if(type == "block") - benchmark("Block Cipher", rng, seconds); - else if(type == "stream") - benchmark("Stream Cipher", rng, seconds); - else if(type == "hash") - benchmark("Hash", rng, seconds); - else if(type == "mode") - benchmark("Cipher Mode", rng, seconds); - else if(type == "mac") - benchmark("MAC", rng, seconds); - else if(type == "rng") - benchmark("RNG", rng, seconds); - else if(type == "pk") - bench_pk(rng, "All", seconds); - else - std::cerr << "Unknown --bench-type " << type << "\n"; - } } } catch(std::exception& e) diff --git a/checks/clock.cpp b/checks/clock.cpp deleted file mode 100644 index e5565ff9c..000000000 --- a/checks/clock.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "timer.h" -#include - -/************************************************* -* Platform specific settings for which clock type to use -*/ - -#if !defined(USE_CLOCK_GETTIME) && defined(BOTAN_TARGET_OS_IS_LINUX) - #define USE_GETTIMEOFDAY 1 -#endif - -#if !defined(USE_GETTIMEOFDAY) && defined(BOTAN_TARGET_OS_IS_FREEBSD) - #define USE_GETTIMEOFDAY 1 -#endif - -/************************************************* - Set the default, which is clock -*/ -#ifndef USE_CLOCK_GETTIME - #define USE_CLOCK_GETTIME 0 -#endif - -#ifndef USE_GETTIMEOFDAY - #define USE_GETTIMEOFDAY 0 -#endif - -#ifndef USE_TIMES - #define USE_TIMES 0 -#endif - -/* the default: ANSI/ISO clock */ -#ifndef USE_CLOCK - #define USE_CLOCK 1 -#endif - -#if USE_CLOCK_GETTIME - #include -#elif USE_GETTIMEOFDAY - #include -#elif USE_TIMES - #include - #include -#elif USE_CLOCK - #include -#endif - -/* The implementation: */ -u64bit Timer::get_clock() - { - static const u64bit billion = 1000000000; - -#if USE_CLOCK_GETTIME - - struct timespec tv; - clock_gettime(CLOCK_REALTIME, &tv); - return (billion * tv.tv_sec + tv.tv_nsec); - -#elif USE_GETTIMEOFDAY - - struct timeval tv; - gettimeofday(&tv, 0); - return (billion * tv.tv_sec + 1000 * tv.tv_usec); - -#elif USE_TIMES - - struct tms tms; - times(&tms); - - static const u64bit clocks_to_nanoseconds = - (billion / sysconf(_SC_CLK_TCK)); - - return (tms.tms_utime * clocks_to_nanoseconds); - -#elif USE_CLOCK - - static const u64bit clocks_to_nanoseconds = - (billion / CLOCKS_PER_SEC); - - return clock() * clocks_to_nanoseconds; - -#endif - } diff --git a/checks/common.h b/checks/common.h index fa41882ee..5b8f0a5d0 100644 --- a/checks/common.h +++ b/checks/common.h @@ -14,20 +14,7 @@ using Botan::byte; using Botan::u32bit; - -struct algorithm - { - algorithm(const char* t, const char* n, - u32bit k = 0, u32bit i = 0) : - type(t), name(n), filtername(n), keylen(k), ivlen(i) {} - algorithm(const char* t, const char* n, - const char* f, u32bit k = 0, u32bit i = 0) : - type(t), name(n), filtername(f), keylen(k), ivlen(i) {} - std::string type, name, filtername; - u32bit keylen, ivlen, weight; - }; - -std::vector get_algos(); +using Botan::u64bit; void strip_comments(std::string& line); void strip_newlines(std::string& line); diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp index fcc0a0f13..9a94d8474 100644 --- a/checks/pk_bench.cpp +++ b/checks/pk_bench.cpp @@ -53,9 +53,23 @@ using namespace Botan; #include #include #include +#include namespace { +class Benchmark_Report + { + public: + void report(const std::string& name, Timer timer) + { + std::cout << name << " " << timer << std::endl; + data[name].insert(timer); + } + + private: + std::map > data; + }; + void benchmark_enc_dec(PK_Encryptor& enc, PK_Decryptor& dec, Timer& enc_timer, Timer& dec_timer, RandomNumberGenerator& rng, diff --git a/checks/timer.cpp b/checks/timer.cpp index c42aaa4b2..8460257d4 100644 --- a/checks/timer.cpp +++ b/checks/timer.cpp @@ -1,4 +1,5 @@ #include "timer.h" +#include #include Timer::Timer(const std::string& n, u32bit e_mul) : @@ -29,6 +30,12 @@ void Timer::stop() } } +u64bit Timer::get_clock() + { + Botan::Default_Benchmark_Timer timer; + return timer.clock(); + } + std::ostream& operator<<(std::ostream& out, Timer& timer) { //out << timer.value() << " "; -- cgit v1.2.3