Perform one KDF benchmark at a time

* Prevent using double memory when benchmarking Argon2 performance.
* Improve benchmark results by not overusing CPU and memory simultaneously. Parallel benchmarks were causing artificially strained calculations resulting in a lower than desired number of rounds.
This commit is contained in:
Jonathan White 2020-04-07 11:04:40 -04:00
parent 7b25fe9cc6
commit 2022a5e65c

View File

@ -71,16 +71,19 @@ void Kdf::randomizeSeed()
int Kdf::benchmark(int msec) const
{
BenchmarkThread thread1(msec, this);
BenchmarkThread thread2(msec, this);
// Run the benchmark twice using half the time for each run
BenchmarkThread thread(msec / 2, this);
int rounds = 0;
thread1.start();
thread2.start();
thread.start();
thread.wait();
rounds += thread.rounds();
thread1.wait();
thread2.wait();
thread.start();
thread.wait();
rounds += thread.rounds();
return qMax(1, (thread1.rounds() + thread2.rounds()) / 2);
return qMax(1, rounds);
}
Kdf::BenchmarkThread::BenchmarkThread(int msec, const Kdf* kdf)