diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-12 15:41:59 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-12 15:41:59 +0100 |
commit | 640d097fdb1c34bc77f2e592fe44fb58c4f8d1ef (patch) | |
tree | ef0208127d884598b309fa02c153777c73b37bc4 /tests/storagebenchmark.cpp | |
parent | fe2e3d5474549c04ecc9abed9029fabcf645f90a (diff) | |
download | sink-640d097fdb1c34bc77f2e592fe44fb58c4f8d1ef.tar.gz sink-640d097fdb1c34bc77f2e592fe44fb58c4f8d1ef.zip |
Benchmark findLatest
It's not much slower if there is only one matching entry
Diffstat (limited to 'tests/storagebenchmark.cpp')
-rw-r--r-- | tests/storagebenchmark.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
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: | |||
153 | void testKeyLookup() | 153 | void testKeyLookup() |
154 | { | 154 | { |
155 | QScopedPointer<Sink::Storage> store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadOnly)); | 155 | QScopedPointer<Sink::Storage> store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadOnly)); |
156 | auto transaction = store->createTransaction(Sink::Storage::ReadOnly); | ||
157 | auto db = transaction.openDatabase(); | ||
156 | 158 | ||
157 | QBENCHMARK { | 159 | QBENCHMARK { |
158 | int hit = 0; | 160 | int hit = 0; |
159 | store->createTransaction(Sink::Storage::ReadOnly).openDatabase().scan("key40000", [&](const QByteArray &key, const QByteArray &value) -> bool { | 161 | db.scan("key40000", [&](const QByteArray &key, const QByteArray &value) -> bool { |
162 | hit++; | ||
163 | return true; | ||
164 | }); | ||
165 | QCOMPARE(hit, 1); | ||
166 | } | ||
167 | } | ||
168 | |||
169 | void testFindLatest() | ||
170 | { | ||
171 | QScopedPointer<Sink::Storage> store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadOnly)); | ||
172 | auto transaction = store->createTransaction(Sink::Storage::ReadOnly); | ||
173 | auto db = transaction.openDatabase(); | ||
174 | |||
175 | QBENCHMARK { | ||
176 | int hit = 0; | ||
177 | db.findLatest("key40000", [&](const QByteArray &key, const QByteArray &value) -> bool { | ||
160 | hit++; | 178 | hit++; |
161 | return true; | 179 | return true; |
162 | }); | 180 | }); |