summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/storagebenchmark.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/tests/storagebenchmark.cpp b/tests/storagebenchmark.cpp
index 665008d..bfdd2ce 100644
--- a/tests/storagebenchmark.cpp
+++ b/tests/storagebenchmark.cpp
@@ -79,9 +79,9 @@ private Q_SLOTS:
79 QFETCH(bool, useDb); 79 QFETCH(bool, useDb);
80 QFETCH(int, count); 80 QFETCH(int, count);
81 81
82 Storage *store = 0; 82 QScopedPointer<Storage> store;
83 if (useDb) { 83 if (useDb) {
84 store = new Storage(testDataPath, dbName, Storage::ReadWrite); 84 store.reset(new Storage(testDataPath, dbName, Storage::ReadWrite));
85 } 85 }
86 86
87 std::ofstream myfile; 87 std::ofstream myfile;
@@ -133,8 +133,40 @@ private Q_SLOTS:
133 } else { 133 } else {
134 qDebug() << "File reading is not implemented."; 134 qDebug() << "File reading is not implemented.";
135 } 135 }
136 }
137
138 void testScan()
139 {
140 QScopedPointer<Storage> store(new Storage(testDataPath, dbName, Storage::ReadOnly));
141
142 QBENCHMARK {
143 int hit = 0;
144 store->scan("", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool {
145 if (std::string(static_cast<char*>(keyValue), keySize) == "key10000") {
146 qDebug() << "hit";
147 hit++;
148 }
149 return true;
150 });
151 QCOMPARE(hit, 1);
152 }
153 }
136 154
137 delete store; 155 void testKeyLookup()
156 {
157 QScopedPointer<Storage> store(new Storage(testDataPath, dbName, Storage::ReadOnly));
158
159 QBENCHMARK {
160 int hit = 0;
161 store->scan("key40000", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool {
162 if (std::string(static_cast<char*>(keyValue), keySize) == "foo") {
163 qDebug() << "hit";
164 }
165 hit++;
166 return true;
167 });
168 QCOMPARE(hit, 1);
169 }
138 } 170 }
139 171
140 void testBufferCreation() 172 void testBufferCreation()