summaryrefslogtreecommitdiff
path: root/bench.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-03-08 16:59:24 -0500
committerJeffrey Walton <noloader@gmail.com>2017-03-08 16:59:24 -0500
commitce38a411fc5324a2868da9fae890365d19a5757e (patch)
tree45c22de8a1f1312230b22c49805cb0a0cd65924d /bench.h
parent2416c0eaf558060d93b8d9cc726c75f60cf28c5c (diff)
downloadcryptopp-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.h44
1 files changed, 27 insertions, 17 deletions
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 <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