summaryrefslogtreecommitdiffstats
path: root/tests/storagebenchmark.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-10 00:49:14 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-10 00:49:14 +0200
commite2b2fc762f02214dbfbc63d6f04546cd3a0a31cb (patch)
tree56286a530d6270821f99e5dea89e3afd3f4e058a /tests/storagebenchmark.cpp
parent9e39e9c72b05110a72ef4e84b4bec8bf3c2404f9 (diff)
downloadsink-e2b2fc762f02214dbfbc63d6f04546cd3a0a31cb.tar.gz
sink-e2b2fc762f02214dbfbc63d6f04546cd3a0a31cb.zip
Use new store API in storagebenchmark
Diffstat (limited to 'tests/storagebenchmark.cpp')
-rw-r--r--tests/storagebenchmark.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/tests/storagebenchmark.cpp b/tests/storagebenchmark.cpp
index 4f6449b..fba72ad 100644
--- a/tests/storagebenchmark.cpp
+++ b/tests/storagebenchmark.cpp
@@ -92,28 +92,26 @@ private Q_SLOTS:
92 const char *keyPrefix = "key"; 92 const char *keyPrefix = "key";
93 93
94 QTime time; 94 QTime time;
95
96 time.start(); 95 time.start();
97 { 96 {
98 auto event = createEvent(); 97 auto event = createEvent();
99 for (int i = 0; i < count; i++) { 98 if (store) {
100 if (store) { 99 auto transaction = store->createTransaction(Akonadi2::Storage::ReadWrite);
100 for (int i = 0; i < count; i++) {
101 if (i % 10000 == 0) { 101 if (i % 10000 == 0) {
102 if (i > 0) { 102 if (i > 0) {
103 store->commitTransaction(); 103 transaction.commit();
104 transaction = std::move(store->createTransaction(Akonadi2::Storage::ReadWrite));
104 } 105 }
105 store->startTransaction();
106 } 106 }
107 107
108 store->write(keyPrefix + QByteArray::number(i), event); 108 transaction.write(keyPrefix + QByteArray::number(i), event);
109 } else {
110 myfile << event.toStdString();
111 } 109 }
112 } 110 transaction.commit();
113
114 if (store) {
115 store->commitTransaction();
116 } else { 111 } else {
112 for (int i = 0; i < count; i++) {
113 myfile << event.toStdString();
114 }
117 myfile.close(); 115 myfile.close();
118 } 116 }
119 } 117 }
@@ -122,9 +120,10 @@ private Q_SLOTS:
122 qDebug() << "Writing took[ms]: " << writeDuration << "->" << writeOpsPerMs << "ops/ms"; 120 qDebug() << "Writing took[ms]: " << writeDuration << "->" << writeOpsPerMs << "ops/ms";
123 121
124 { 122 {
125 for (int i = 0; i < count; i++) { 123 if (store) {
126 if (store) { 124 auto transaction = store->createTransaction(Akonadi2::Storage::ReadOnly);
127 store->scan(keyPrefix + QByteArray::number(i), [](const QByteArray &value) -> bool { return true; }); 125 for (int i = 0; i < count; i++) {
126 transaction.scan(keyPrefix + QByteArray::number(i), [](const QByteArray &key, const QByteArray &value) -> bool { return true; });
128 } 127 }
129 } 128 }
130 } 129 }
@@ -152,8 +151,8 @@ private Q_SLOTS:
152 151
153 QBENCHMARK { 152 QBENCHMARK {
154 int hit = 0; 153 int hit = 0;
155 store->scan("", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool { 154 store->createTransaction(Akonadi2::Storage::ReadOnly).scan("", [&](const QByteArray &key, const QByteArray &value) -> bool {
156 if (std::string(static_cast<char*>(keyValue), keySize) == "key10000") { 155 if (key == "key10000") {
157 //qDebug() << "hit"; 156 //qDebug() << "hit";
158 hit++; 157 hit++;
159 } 158 }
@@ -169,12 +168,7 @@ private Q_SLOTS:
169 168
170 QBENCHMARK { 169 QBENCHMARK {
171 int hit = 0; 170 int hit = 0;
172 store->scan("key40000", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool { 171 store->createTransaction(Akonadi2::Storage::ReadOnly).scan("key40000", [&](const QByteArray &key, const QByteArray &value) -> bool {
173 /*
174 if (std::string(static_cast<char*>(keyValue), keySize) == "foo") {
175 qDebug() << "hit";
176 }
177 */
178 hit++; 172 hit++;
179 return true; 173 return true;
180 }); 174 });