mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
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:
parent
7b25fe9cc6
commit
2022a5e65c
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user