File indexing completed on 2025-01-18 09:54:54
0001
0002
0003
0004 #ifndef CRYPTOPP_BENCH_H
0005 #define CRYPTOPP_BENCH_H
0006
0007 #include "cryptlib.h"
0008
0009 #include <iostream>
0010 #include <iomanip>
0011 #include <cmath>
0012 #include <ctime>
0013
0014 NAMESPACE_BEGIN(CryptoPP)
0015 NAMESPACE_BEGIN(Test)
0016
0017
0018 enum TestClass {
0019
0020 UnkeyedRNG=(1<<0),
0021
0022 UnkeyedHash=(1<<1),
0023
0024 UnkeyedOther=(1<<2),
0025
0026
0027 SharedKeyMAC=(1<<3),
0028
0029 SharedKeyStream=(1<<4),
0030
0031 SharedKeyBlock=(1<<5),
0032
0033 SharedKeyOther=(1<<6),
0034
0035
0036 PublicKeyAgreement=(1<<7),
0037
0038 PublicKeyEncryption=(1<<8),
0039
0040 PublicKeySignature=(1<<9),
0041
0042 PublicKeyOther=(1<<10),
0043
0044
0045 PublicKeyAgreementEC=(1<<11),
0046
0047 PublicKeyEncryptionEC=(1<<12),
0048
0049 PublicKeySignatureEC=(1<<13),
0050
0051 PublicKeyOtherEC=(1<<14),
0052
0053 Unkeyed=UnkeyedRNG|UnkeyedHash|UnkeyedOther,
0054 SharedKey=SharedKeyMAC|SharedKeyStream|SharedKeyBlock|SharedKeyOther,
0055 PublicKey=PublicKeyAgreement|PublicKeyEncryption|PublicKeySignature|PublicKeyOther,
0056 PublicKeyEC=PublicKeyAgreementEC|PublicKeyEncryptionEC|PublicKeySignatureEC|PublicKeyOtherEC,
0057
0058 All=Unkeyed|SharedKey|PublicKey|PublicKeyEC,
0059
0060 TestFirst=(0), TestLast=(1<<15)
0061 };
0062
0063 extern const double CLOCK_TICKS_PER_SECOND;
0064 extern double g_allocatedTime;
0065 extern double g_hertz;
0066 extern double g_logTotal;
0067 extern unsigned int g_logCount;
0068 extern const byte defaultKey[];
0069
0070
0071 extern time_t g_testBegin;
0072 extern time_t g_testEnd;
0073
0074
0075 void BenchmarkWithCommand(int argc, const char* const argv[]);
0076
0077 void Benchmark(Test::TestClass suites, double t, double hertz);
0078
0079 void BenchmarkUnkeyedAlgorithms(double t, double hertz);
0080
0081 void BenchmarkSharedKeyedAlgorithms(double t, double hertz);
0082
0083 void BenchmarkPublicKeyAlgorithms(double t, double hertz);
0084
0085 void BenchmarkEllipticCurveAlgorithms(double t, double hertz);
0086
0087
0088 extern void OutputResultKeying(double iterations, double timeTaken);
0089 extern void OutputResultBytes(const char *name, const char *provider, double length, double timeTaken);
0090 extern void OutputResultOperations(const char *name, const char *provider, const char *operation, bool pc, unsigned long iterations, double timeTaken);
0091
0092
0093 extern void BenchMark(const char *name, BufferedTransformation &bt, double timeTotal);
0094 extern void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal);
0095 extern void BenchMark(const char *name, HashTransformation &ht, double timeTotal);
0096 extern void BenchMark(const char *name, RandomNumberGenerator &rng, double timeTotal);
0097
0098
0099 extern void BenchMarkKeying(SimpleKeyingInterface &c, size_t keyLength, const NameValuePairs ¶ms);
0100 extern void BenchMark(const char *name, AuthenticatedSymmetricCipher &cipher, double timeTotal);
0101
0102 NAMESPACE_END
0103 NAMESPACE_END
0104
0105 #endif