diff options
author | Jeffrey Walton <noloader@gmail.com> | 2017-03-08 16:59:24 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2017-03-08 16:59:24 -0500 |
commit | ce38a411fc5324a2868da9fae890365d19a5757e (patch) | |
tree | 45c22de8a1f1312230b22c49805cb0a0cd65924d /bench.h | |
parent | 2416c0eaf558060d93b8d9cc726c75f60cf28c5c (diff) | |
download | cryptopp-git-ce38a411fc5324a2868da9fae890365d19a5757e.tar.gz |
Add Random Number Generator benchmarks (Issue 386)
Move HTML header and footer into benchmark functions
Switch to <cmath> and standard math routines
Switch to <ctime> and standard clock and time routines
Move static variable^Cinto anonymous namespace
Add TimeToString function for printing start and end times
Diffstat (limited to 'bench.h')
-rw-r--r-- | bench.h | 44 |
1 files changed, 27 insertions, 17 deletions
@@ -6,26 +6,36 @@ #include "cryptlib.h"
+#include <iostream>
+#include <iomanip>
+#include <cmath>
+#include <ctime>
+
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
|