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  Unkeyed=1,SharedKeyMAC=2,SharedKeyStream=4,SharedKeyBlock=8,SharedKeyOther=16,
20  PublicKeyAgreement=32,PublicKeyEncryption=64,PublicKeySignature=128,PublicKeyOther=256,
21  SharedKey=SharedKeyMAC|SharedKeyStream|SharedKeyBlock|SharedKeyOther,
22  PublicKey=PublicKeyAgreement|PublicKeyEncryption|PublicKeySignature|PublicKeyOther,
23  All=Unkeyed|SharedKey|PublicKey
24 };
25 
26 extern const double CLOCK_TICKS_PER_SECOND;
27 extern double g_allocatedTime;
28 extern double g_hertz;
29 extern double g_logTotal;
30 extern unsigned int g_logCount;
31 extern const byte defaultKey[];
32 
33 // Test book keeping
34 extern time_t g_testBegin;
35 extern time_t g_testEnd;
36 
37 // Command handler
38 void BenchmarkWithCommand(int argc, const char* const argv[]);
39 // Top level, prints preamble and postamble
40 void Benchmark(Test::TestClass suites, double t, double hertz);
41 // Unkeyed systems
42 void Benchmark1(double t, double hertz);
43 // Shared key systems
44 void Benchmark2(double t, double hertz);
45 // Public key systems
46 void Benchmark3(double t, double hertz);
47 
48 void OutputResultBytes(const char *name, double length, double timeTaken);
49 void OutputResultOperations(const char *name, const char *operation, bool pc, unsigned long iterations, double timeTaken);
50 
51 NAMESPACE_END // Test
52 NAMESPACE_END // CryptoPP
53 
54 #endif
Abstract base classes that provide a uniform interface to this library.
Interface for public keys.
Definition: cryptlib.h:2160
Crypto++ library namespace.