summaryrefslogtreecommitdiffstats
path: root/tests/genericresourcebenchmark.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-23 18:56:43 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-23 18:56:43 +0200
commit1acf9f3c486813df807ff6931e56cc13eb26eeaf (patch)
tree559ead2e95986515b4a5f93b6f143b8f1d429bd3 /tests/genericresourcebenchmark.cpp
parent62e7084dcd6f53275fcb21ba17e880e41b40094d (diff)
downloadsink-1acf9f3c486813df807ff6931e56cc13eb26eeaf.tar.gz
sink-1acf9f3c486813df807ff6931e56cc13eb26eeaf.zip
Store indexes as named databases in the same db.
Because we also keep using the same transactions this finally makes the resource somewhat performant. On my system genericresourcebenchmark now processes ~4200 messages per second instead of ~280.
Diffstat (limited to 'tests/genericresourcebenchmark.cpp')
-rw-r--r--tests/genericresourcebenchmark.cpp56
1 files changed, 51 insertions, 5 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;