Crypto++  8.2
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 // Benchmark 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 // These are defined in bench1.cpp
52 extern void OutputResultKeying(double iterations, double timeTaken);
53 extern void OutputResultBytes(const char *name, const char *provider, double length, double timeTaken);
54 extern void OutputResultOperations(const char *name, const char *provider, const char *operation, bool pc, unsigned long iterations, double timeTaken);
55 
56 // These are defined in bench1.cpp
57 extern void BenchMark(const char *name, BufferedTransformation &bt, double timeTotal);
58 extern void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal);
59 extern void BenchMark(const char *name, HashTransformation &ht, double timeTotal);
60 extern void BenchMark(const char *name, RandomNumberGenerator &rng, double timeTotal);
61 
62 // These are defined in bench2.cpp
63 extern void BenchMarkKeying(SimpleKeyingInterface &c, size_t keyLength, const NameValuePairs &params);
64 extern void BenchMark(const char *name, AuthenticatedSymmetricCipher &cipher, double timeTotal);
65 
66 NAMESPACE_END // Test
67 NAMESPACE_END // CryptoPP
68 
69 #endif
Interface for authenticated encryption modes of operation.
Definition: cryptlib.h:1288
Abstract base classes that provide a uniform interface to this library.
Interface for random number generators.
Definition: cryptlib.h:1383
Interface for buffered transformations.
Definition: cryptlib.h:1598
Interface for algorithms that take byte strings as keys.
Definition: cryptlib.h:613
Namespace containing testing and benchmark classes.
Definition: cryptlib.h:547
Interface for the data processing portion of stream ciphers.
Definition: cryptlib.h:917
Interface for hash functions and data processing part of MACs.
Definition: cryptlib.h:1084
Interface for public keys.
Definition: cryptlib.h:2425
Crypto++ library namespace.
Interface for retrieving values given their names.
Definition: cryptlib.h:293