From b07de47e3514116cc38b237016e18a18edfebe7b Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sun, 19 Jan 2014 15:26:32 +0100 Subject: [PATCH] Add transform key benchmark to TestKeys. --- tests/TestKeys.cpp | 20 ++++++++++++++++++++ tests/TestKeys.h | 1 + 2 files changed, 21 insertions(+) diff --git a/tests/TestKeys.cpp b/tests/TestKeys.cpp index 00b2ffa36..ec9a35b4b 100644 --- a/tests/TestKeys.cpp +++ b/tests/TestKeys.cpp @@ -165,4 +165,24 @@ void TestKeys::testFileKeyError() errorMsg = ""; } +void TestKeys::benchmarkTransformKey() +{ + QByteArray env = qgetenv("BENCHMARK"); + + if (env.isEmpty() || env == "0" || env == "no") { + QSKIP("Benchmark skipped. Set env variable BENCHMARK=1 to enable.", SkipAll); + } + + PasswordKey pwKey; + pwKey.setPassword("password"); + CompositeKey compositeKey; + compositeKey.addKey(pwKey); + + QByteArray seed(32, '\x4B'); + + QBENCHMARK { + compositeKey.transform(seed, 1e6); + } +} + QTEST_GUILESS_MAIN(TestKeys) diff --git a/tests/TestKeys.h b/tests/TestKeys.h index f6677ec7d..0f14117fd 100644 --- a/tests/TestKeys.h +++ b/tests/TestKeys.h @@ -31,6 +31,7 @@ private Q_SLOTS: void testFileKey_data(); void testCreateFileKey(); void testFileKeyError(); + void benchmarkTransformKey(); }; #endif // KEEPASSX_TESTKEYS_H