summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/genericresourcebenchmark.cpp56
-rw-r--r--tests/storagetest.cpp4
2 files changed, 53 insertions, 7 deletions
diff --git a/tests/genericresourcebenchmark.cpp b/tests/genericresourcebenchmark.cpp
index 01dc95d..27678b0 100644
--- a/tests/genericresourcebenchmark.cpp
+++ b/tests/genericresourcebenchmark.cpp
@@ -12,6 +12,7 @@
12#include "genericresource.h" 12#include "genericresource.h"
13#include "definitions.h" 13#include "definitions.h"
14#include "domainadaptor.h" 14#include "domainadaptor.h"
15#include "index.h"
15#include <iostream> 16#include <iostream>
16 17
17class TestResource : public Akonadi2::GenericResource 18class TestResource : public Akonadi2::GenericResource
@@ -89,19 +90,20 @@ private Q_SLOTS:
89 90
90 void init() 91 void init()
91 { 92 {
93 Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Warning);
94 }
95
96 void initTestCase()
97 {
92 removeFromDisk("org.kde.test.instance1"); 98 removeFromDisk("org.kde.test.instance1");
93 removeFromDisk("org.kde.test.instance1.userqueue"); 99 removeFromDisk("org.kde.test.instance1.userqueue");
94 removeFromDisk("org.kde.test.instance1.synchronizerqueue"); 100 removeFromDisk("org.kde.test.instance1.synchronizerqueue");
95 Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Warning);
96 qDebug();
97 qDebug() << "-----------------------------------------";
98 qDebug();
99 } 101 }
100 102
101 103
102 void testWriteInProcess() 104 void testWriteInProcess()
103 { 105 {
104 int num = 50000; 106 int num = 10000;
105 107
106 auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.test.instance1"); 108 auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.test.instance1");
107 TestResource resource("org.kde.test.instance1", pipeline); 109 TestResource resource("org.kde.test.instance1", pipeline);
@@ -125,6 +127,50 @@ private Q_SLOTS:
125 std::cout << "All processed: " << allProcessedTime << " /sec " << num*1000/allProcessedTime << std::endl; 127 std::cout << "All processed: " << allProcessedTime << " /sec " << num*1000/allProcessedTime << std::endl;
126 } 128 }
127 129
130 void testWriteInProcessWithIndex()
131 {
132 int num = 10000;
133
134 auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.test.instance1");
135
136 auto eventFactory = QSharedPointer<TestEventAdaptorFactory>::create();
137 const QByteArray resourceIdentifier = "org.kde.test.instance1";
138 auto eventIndexer = new Akonadi2::SimpleProcessor("eventIndexer", [eventFactory, resourceIdentifier](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity, Akonadi2::Storage::Transaction &transaction) {
139 auto adaptor = eventFactory->createAdaptor(entity);
140 Akonadi2::ApplicationDomain::Event event(resourceIdentifier, state.key(), -1, adaptor);
141 Akonadi2::ApplicationDomain::TypeImplementation<Akonadi2::ApplicationDomain::Event>::index(event, transaction);
142
143 //Create a bunch of indexes
144 for (int i = 0; i < 10; i++) {
145 Index ridIndex(QString("index.index%1").arg(i).toLatin1(), transaction);
146 ridIndex.add("foo", event.identifier());
147 }
148 });
149
150 pipeline->setPreprocessors("event", Akonadi2::Pipeline::NewPipeline, QVector<Akonadi2::Preprocessor*>() << eventIndexer);
151 pipeline->setAdaptorFactory("event", eventFactory);
152
153 TestResource resource("org.kde.test.instance1", pipeline);
154
155 auto command = createEntityBuffer();
156
157 QTime time;
158 time.start();
159
160 for (int i = 0; i < num; i++) {
161 resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command);
162 }
163 auto appendTime = time.elapsed();
164
165 //Wait until all messages have been processed
166 resource.processAllMessages().exec().waitForFinished();
167
168 auto allProcessedTime = time.elapsed();
169
170 std::cout << "Append to messagequeue " << appendTime << " /sec " << num*1000/appendTime << std::endl;
171 std::cout << "All processed: " << allProcessedTime << " /sec " << num*1000/allProcessedTime << std::endl;
172 }
173
128 void testCreateCommand() 174 void testCreateCommand()
129 { 175 {
130 Akonadi2::ApplicationDomain::Event event; 176 Akonadi2::ApplicationDomain::Event event;
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp
index e872c44..6ba4bcd 100644
--- a/tests/storagetest.cpp
+++ b/tests/storagetest.cpp
@@ -223,7 +223,7 @@ private Q_SLOTS:
223 bool gotError = false; 223 bool gotError = false;
224 Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite, false); 224 Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite, false);
225 auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); 225 auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite);
226 auto db = transaction.openDatabase(); 226 auto db = transaction.openDatabase("default", nullptr, false);
227 db.write("key","value"); 227 db.write("key","value");
228 db.write("key","value"); 228 db.write("key","value");
229 229
@@ -246,7 +246,7 @@ private Q_SLOTS:
246 bool gotError = false; 246 bool gotError = false;
247 Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite, true); 247 Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite, true);
248 auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); 248 auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite);
249 auto db = transaction.openDatabase(); 249 auto db = transaction.openDatabase("default", nullptr, true);
250 db.write("key","value1"); 250 db.write("key","value1");
251 db.write("key","value2"); 251 db.write("key","value2");
252 int numValues = db.scan("key", [&](const QByteArray &key, const QByteArray &value) -> bool { 252 int numValues = db.scan("key", [&](const QByteArray &key, const QByteArray &value) -> bool {