Crypto++ 8.2
Free C&
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
14NAMESPACE_BEGIN(CryptoPP)
15NAMESPACE_BEGIN(Test)
16
17// More granular control over benchmarks
18enum 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
29extern const double CLOCK_TICKS_PER_SECOND;
30extern double g_allocatedTime;
31extern double g_hertz;
32extern double g_logTotal;
33extern unsigned int g_logCount;
34extern const byte defaultKey[];
35
36// Test book keeping
37extern time_t g_testBegin;
38extern time_t g_testEnd;
39
40// Benchmark command handler
41void BenchmarkWithCommand(int argc, const char* const argv[]);
42// Top level, prints preamble and postamble
43void Benchmark(Test::TestClass suites, double t, double hertz);
44// Unkeyed systems
45void Benchmark1(double t, double hertz);
46// Shared key systems
47void Benchmark2(double t, double hertz);
48// Public key systems
49void Benchmark3(double t, double hertz);
50
51// These are defined in bench1.cpp
52extern void OutputResultKeying(double iterations, double timeTaken);
53extern void OutputResultBytes(const char *name, const char *provider, double length, double timeTaken);
54extern 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
57extern void BenchMark(const char *name, BufferedTransformation &bt, double timeTotal);
58extern void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal);
59extern void BenchMark(const char *name, HashTransformation &ht, double timeTotal);
60extern void BenchMark(const char *name, RandomNumberGenerator &rng, double timeTotal);
61
62// These are defined in bench2.cpp
63extern void BenchMarkKeying(SimpleKeyingInterface &c, size_t keyLength, const NameValuePairs &params);
64extern void BenchMark(const char *name, AuthenticatedSymmetricCipher &cipher, double timeTotal);
65
66NAMESPACE_END // Test
67NAMESPACE_END // CryptoPP
68
69#endif
Interface for authenticated encryption modes of operation.
Definition: cryptlib.h:1289
Interface for buffered transformations.
Definition: cryptlib.h:1599
Interface for hash functions and data processing part of MACs.
Definition: cryptlib.h:1085
Interface for retrieving values given their names.
Definition: cryptlib.h:294
Interface for public keys.
Definition: cryptlib.h:2426
Interface for random number generators.
Definition: cryptlib.h:1384
Interface for algorithms that take byte strings as keys.
Definition: cryptlib.h:614
Interface for the data processing portion of stream ciphers.
Definition: cryptlib.h:918
Abstract base classes that provide a uniform interface to this library.
Crypto++ library namespace.
Namespace containing testing and benchmark classes.
Definition: cryptlib.h:547