diff options
author | Jeffrey Walton <noloader@gmail.com> | 2020-12-15 22:53:09 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2020-12-15 22:53:09 -0500 |
commit | d7b2982e32150096a454588fa3ad6a0d9f08f955 (patch) | |
tree | 1de7450fada6e99f04e405aa40e06946eadb10c0 /bench1.cpp | |
parent | bfeba0d300fa53a974922c07c5b816e65b266b6f (diff) | |
download | cryptopp-git-d7b2982e32150096a454588fa3ad6a0d9f08f955.tar.gz |
Reduce benchmark running time to 10 seconds if excessive (GH #983)
Diffstat (limited to 'bench1.cpp')
-rw-r--r-- | bench1.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
@@ -349,6 +349,10 @@ void BenchmarkWithCommand(int argc, const char* const argv[]) float cpuFreq(argc >= 4 ? Test::StringToValue<float, true>(argv[3])*float(1e9) : 0.0f);
std::string algoName(argc >= 5 ? argv[4] : "");
+ // https://github.com/weidai11/cryptopp/issues/983
+ if (runningTime > 10.0f)
+ runningTime = 10.0f;
+
if (command == "b") // All benchmarks
Benchmark(Test::All, runningTime, cpuFreq);
else if (command == "b4") // Public key algorithms over EC
@@ -366,6 +370,9 @@ void Benchmark(Test::TestClass suites, double t, double hertz) g_allocatedTime = t;
g_hertz = hertz;
+ // Add <br> in between tables
+ size_t count_breaks = 0;
+
AddHtmlHeader();
g_testBegin = ::time(NULLPTR);
@@ -376,28 +383,40 @@ void Benchmark(Test::TestClass suites, double t, double hertz) // Unkeyed algorithms
if (suites & Test::Unkeyed)
{
- std::cout << "\n<BR>";
+ if (count_breaks)
+ std::cout << "\n<BR>";
+ count_breaks++;
+
Benchmark1(t, hertz);
}
// Shared key algorithms
if (suites & Test::SharedKey)
{
- std::cout << "\n<BR>";
+ if (count_breaks)
+ std::cout << "\n<BR>";
+ count_breaks++;
+
Benchmark2(t, hertz);
}
// Public key algorithms
if (suites & Test::PublicKey)
{
- std::cout << "\n<BR>";
+ if (count_breaks)
+ std::cout << "\n<BR>";
+ count_breaks++;
+
Benchmark3(t, hertz);
}
// Public key algorithms over EC
if (suites & Test::PublicKeyEC)
{
- std::cout << "\n<BR>";
+ if (count_breaks)
+ std::cout << "\n<BR>";
+ count_breaks++;
+
Benchmark4(t, hertz);
}
|