diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-25 00:37:42 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-25 00:37:42 +0100 |
commit | e4a4d72fd206fc2d5c1095b39b2839e53cd114bb (patch) | |
tree | bf1edb0a483c12cda89973b3f073cd44b00286b4 /tests/storagetest.cpp | |
parent | 9ad96df6cd1526de32bff2b4f98491dd8318f760 (diff) | |
download | sink-e4a4d72fd206fc2d5c1095b39b2839e53cd114bb.tar.gz sink-e4a4d72fd206fc2d5c1095b39b2839e53cd114bb.zip |
Optimize findLast
This just gave a 700% boost to query performance from ~2k
to 14k reads per second...
Diffstat (limited to 'tests/storagetest.cpp')
-rw-r--r-- | tests/storagetest.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp index bef8755..d950961 100644 --- a/tests/storagetest.cpp +++ b/tests/storagetest.cpp | |||
@@ -376,6 +376,7 @@ private Q_SLOTS: | |||
376 | db.write("sub1","value1"); | 376 | db.write("sub1","value1"); |
377 | db.write("sub2","value2"); | 377 | db.write("sub2","value2"); |
378 | db.write("wub3","value3"); | 378 | db.write("wub3","value3"); |
379 | db.write("wub4","value4"); | ||
379 | QByteArray result; | 380 | QByteArray result; |
380 | db.findLatest("sub", [&](const QByteArray &key, const QByteArray &value) { | 381 | db.findLatest("sub", [&](const QByteArray &key, const QByteArray &value) { |
381 | result = value; | 382 | result = value; |
@@ -384,6 +385,35 @@ private Q_SLOTS: | |||
384 | QCOMPARE(result, QByteArray("value2")); | 385 | QCOMPARE(result, QByteArray("value2")); |
385 | } | 386 | } |
386 | 387 | ||
388 | void testFindLatestInSingle() | ||
389 | { | ||
390 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | ||
391 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | ||
392 | auto db = transaction.openDatabase("test", nullptr, false); | ||
393 | db.write("sub2","value2"); | ||
394 | QByteArray result; | ||
395 | db.findLatest("sub", [&](const QByteArray &key, const QByteArray &value) { | ||
396 | result = value; | ||
397 | }); | ||
398 | |||
399 | QCOMPARE(result, QByteArray("value2")); | ||
400 | } | ||
401 | |||
402 | void testFindLast() | ||
403 | { | ||
404 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | ||
405 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | ||
406 | auto db = transaction.openDatabase("test", nullptr, false); | ||
407 | db.write("sub2","value2"); | ||
408 | db.write("wub3","value3"); | ||
409 | QByteArray result; | ||
410 | db.findLatest("wub", [&](const QByteArray &key, const QByteArray &value) { | ||
411 | result = value; | ||
412 | }); | ||
413 | |||
414 | QCOMPARE(result, QByteArray("value3")); | ||
415 | } | ||
416 | |||
387 | void testRecordRevision() | 417 | void testRecordRevision() |
388 | { | 418 | { |
389 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 419 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); |