From 640d097fdb1c34bc77f2e592fe44fb58c4f8d1ef Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 12 Feb 2016 15:41:59 +0100 Subject: Benchmark findLatest It's not much slower if there is only one matching entry --- tests/storagebenchmark.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/storagebenchmark.cpp b/tests/storagebenchmark.cpp index eada4ee..09cc336 100644 --- a/tests/storagebenchmark.cpp +++ b/tests/storagebenchmark.cpp @@ -153,10 +153,28 @@ private Q_SLOTS: void testKeyLookup() { QScopedPointer store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadOnly)); + auto transaction = store->createTransaction(Sink::Storage::ReadOnly); + auto db = transaction.openDatabase(); QBENCHMARK { int hit = 0; - store->createTransaction(Sink::Storage::ReadOnly).openDatabase().scan("key40000", [&](const QByteArray &key, const QByteArray &value) -> bool { + db.scan("key40000", [&](const QByteArray &key, const QByteArray &value) -> bool { + hit++; + return true; + }); + QCOMPARE(hit, 1); + } + } + + void testFindLatest() + { + QScopedPointer store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadOnly)); + auto transaction = store->createTransaction(Sink::Storage::ReadOnly); + auto db = transaction.openDatabase(); + + QBENCHMARK { + int hit = 0; + db.findLatest("key40000", [&](const QByteArray &key, const QByteArray &value) -> bool { hit++; return true; }); -- cgit v1.2.3