From ce38a411fc5324a2868da9fae890365d19a5757e Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 8 Mar 2017 16:59:24 -0500 Subject: Add Random Number Generator benchmarks (Issue 386) Move HTML header and footer into benchmark functions Switch to and standard math routines Switch to and standard clock and time routines Move static variable^Cinto anonymous namespace Add TimeToString function for printing start and end times --- bench.h | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'bench.h') diff --git a/bench.h b/bench.h index f393cfde..4924d778 100644 --- a/bench.h +++ b/bench.h @@ -6,26 +6,36 @@ #include "cryptlib.h" +#include +#include +#include +#include + NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) -ANONYMOUS_NAMESPACE_BEGIN -#ifdef CLOCKS_PER_SEC -const double CLOCK_TICKS_PER_SECOND = (double)CLOCKS_PER_SEC; -#elif defined(CLK_TCK) -const double CLOCK_TICKS_PER_SECOND = (double)CLK_TCK; -#else -const double CLOCK_TICKS_PER_SECOND = 1000000.0; -#endif - -static const byte defaultKey[] = "0123456789" // 168 + NULL - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - "00000000000000000000000000000000000000000000000000000" - "00000000000000000000000000000000000000000000000000000"; -NAMESPACE_END - -void BenchmarkAll(double t, double hertz); -void BenchmarkAll2(double t, double hertz); +extern const double CLOCK_TICKS_PER_SECOND; +extern double g_allocatedTime; +extern double g_hertz; +extern double g_logTotal; +extern unsigned int g_logCount; +extern const byte defaultKey[]; + +// Test book keeping +extern time_t g_testBegin; +extern time_t g_testEnd; + +// Top level, prints preamble and postamble +void Benchmark(int suites, double t, double hertz); +// Unkeyed systems +void Benchmark1(double t, double hertz); +// Shared key systems +void Benchmark2(double t, double hertz); +// Public key systems +void Benchmark3(double t, double hertz); + +void OutputResultBytes(const char *name, double length, double timeTaken); +void OutputResultOperations(const char *name, const char *operation, bool pc, unsigned long iterations, double timeTaken); NAMESPACE_END // Test NAMESPACE_END // CryptoPP -- cgit v1.2.1