Crypto++  5.6.5
Free C++ class library of cryptographic schemes
bench.h
1 // bench.h - originally written and placed in the public domain by Wei Dai
2 // CryptoPP::Test namespace added by JW in February 2017
3 
4 #ifndef CRYPTOPP_BENCH_H
5 #define CRYPTOPP_BENCH_H
6 
7 #include "cryptlib.h"
8 
9 #include <iostream>
10 #include <iomanip>
11 #include <cmath>
12 #include <ctime>
13 
14 NAMESPACE_BEGIN(CryptoPP)
15 NAMESPACE_BEGIN(Test)
16 
17 // More granular control over benchmarks
18 enum TestClass {
19  UnkeyedRNG=(1<<0),UnkeyedHash=(1<<1),UnkeyedOther=(1<<2),
20  SharedKeyMAC=(1<<3),SharedKeyStream=(1<<4),SharedKeyBlock=(1<<5),SharedKeyOther=(1<<6),
21  PublicKeyAgreement=(1<<7),PublicKeyEncryption=(1<<8),PublicKeySignature=(1<<9),PublicKeyOther=(1<<10),
22  Unkeyed=UnkeyedRNG|UnkeyedHash|UnkeyedOther,
23  SharedKey=SharedKeyMAC|SharedKeyStream|SharedKeyBlock|SharedKeyOther,
24  PublicKey=PublicKeyAgreement|PublicKeyEncryption|PublicKeySignature|PublicKeyOther,
25  All=Unkeyed|SharedKey|PublicKey,
26  TestFirst=(0), TestLast=(1<<11)
27 };
28 
29 extern const double CLOCK_TICKS_PER_SECOND;
30 extern double g_allocatedTime;
31 extern double g_hertz;
32 extern double g_logTotal;
33 extern unsigned int g_logCount;
34 extern const byte defaultKey[];
35 
36 // Test book keeping
37 extern time_t g_testBegin;
38 extern time_t g_testEnd;
39 
40 // Command handler
41 void BenchmarkWithCommand(int argc, const char* const argv[]);
42 // Top level, prints preamble and postamble
43 void Benchmark(Test::TestClass suites, double t, double hertz);
44 // Unkeyed systems
45 void Benchmark1(double t, double hertz);
46 // Shared key systems
47 void Benchmark2(double t, double hertz);
48 // Public key systems
49 void Benchmark3(double t, double hertz);
50 
51 void OutputResultBytes(const char *name, double length, double timeTaken);
52 void OutputResultOperations(const char *name, const char *operation, bool pc, unsigned long iterations, double timeTaken);
53 
54 NAMESPACE_END // Test
55 NAMESPACE_END // CryptoPP
56 
57 #endif
Abstract base classes that provide a uniform interface to this library.
Namespace containing testing and benchmark classes.
Definition: cryptlib.h:552
Interface for public keys.
Definition: cryptlib.h:2295
Crypto++ library namespace.