summaryrefslogtreecommitdiffstats
path: root/tests/dummyresourcebenchmark.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dummyresourcebenchmark.cpp')
-rw-r--r--tests/dummyresourcebenchmark.cpp40
1 files changed, 25 insertions, 15 deletions
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp
index 242ac76..6eaf065 100644
--- a/tests/dummyresourcebenchmark.cpp
+++ b/tests/dummyresourcebenchmark.cpp
@@ -7,9 +7,9 @@
7#include "clientapi.h" 7#include "clientapi.h"
8#include "commands.h" 8#include "commands.h"
9#include "entitybuffer.h" 9#include "entitybuffer.h"
10#include "synclistresult.h"
11#include "pipeline.h" 10#include "pipeline.h"
12#include "log.h" 11#include "log.h"
12#include "resourceconfig.h"
13 13
14#include "event_generated.h" 14#include "event_generated.h"
15#include "entity_generated.h" 15#include "entity_generated.h"
@@ -24,18 +24,20 @@
24class DummyResourceBenchmark : public QObject 24class DummyResourceBenchmark : public QObject
25{ 25{
26 Q_OBJECT 26 Q_OBJECT
27private:
28 int num;
27private Q_SLOTS: 29private Q_SLOTS:
28 void initTestCase() 30 void initTestCase()
29 { 31 {
30 Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Warning); 32 Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Warning);
31 auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); 33 auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy");
32 QVERIFY(factory); 34 QVERIFY(factory);
33 DummyResource::removeFromDisk("org.kde.dummy.instance1"); 35 ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy");
36 num = 5000;
34 } 37 }
35 38
36 void cleanup() 39 void cleanup()
37 { 40 {
38 DummyResource::removeFromDisk("org.kde.dummy.instance1");
39 } 41 }
40 42
41 static KAsync::Job<void> waitForCompletion(QList<KAsync::Future<void> > &futures) 43 static KAsync::Job<void> waitForCompletion(QList<KAsync::Future<void> > &futures)
@@ -68,11 +70,12 @@ private Q_SLOTS:
68 }); 70 });
69 } 71 }
70 72
71 void testWriteToFacadeAndQueryByUid() 73 void testWriteToFacade()
72 { 74 {
75 DummyResource::removeFromDisk("org.kde.dummy.instance1");
76
73 QTime time; 77 QTime time;
74 time.start(); 78 time.start();
75 int num = 100;
76 QList<KAsync::Future<void> > waitCondition; 79 QList<KAsync::Future<void> > waitCondition;
77 for (int i = 0; i < num; i++) { 80 for (int i = 0; i < num; i++) {
78 Akonadi2::ApplicationDomain::Event event("org.kde.dummy.instance1"); 81 Akonadi2::ApplicationDomain::Event event("org.kde.dummy.instance1");
@@ -90,13 +93,17 @@ private Q_SLOTS:
90 query.resources << "org.kde.dummy.instance1"; 93 query.resources << "org.kde.dummy.instance1";
91 query.syncOnDemand = false; 94 query.syncOnDemand = false;
92 query.processAll = true; 95 query.processAll = true;
93 96 Akonadi2::Store::synchronize(query).exec().waitForFinished();
94 query.propertyFilter.insert("uid", "nonexistantuid");
95 async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query));
96 result.exec();
97 } 97 }
98 auto allProcessedTime = time.elapsed(); 98 auto allProcessedTime = time.elapsed();
99 qDebug() << "Append to messagequeue " << appendTime;
100 qDebug() << "All processed: " << allProcessedTime << "/sec " << num*1000/allProcessedTime;
101 }
99 102
103 void testQueryByUid()
104 {
105 QTime time;
106 time.start();
100 //Measure query 107 //Measure query
101 { 108 {
102 time.start(); 109 time.start();
@@ -106,20 +113,17 @@ private Q_SLOTS:
106 query.processAll = false; 113 query.processAll = false;
107 114
108 query.propertyFilter.insert("uid", "testuid"); 115 query.propertyFilter.insert("uid", "testuid");
109 async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); 116 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query);
110 result.exec(); 117 QTRY_COMPARE(model->rowCount(QModelIndex()), num);
111 QCOMPARE(result.size(), num);
112 } 118 }
113 qDebug() << "Append to messagequeue " << appendTime;
114 qDebug() << "All processed: " << allProcessedTime << "/sec " << num*1000/allProcessedTime;
115 qDebug() << "Query Time: " << time.elapsed() << "/sec " << num*1000/time.elapsed(); 119 qDebug() << "Query Time: " << time.elapsed() << "/sec " << num*1000/time.elapsed();
116 } 120 }
117 121
118 void testWriteInProcess() 122 void testWriteInProcess()
119 { 123 {
124 DummyResource::removeFromDisk("org.kde.dummy.instance1");
120 QTime time; 125 QTime time;
121 time.start(); 126 time.start();
122 int num = 100;
123 127
124 auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.dummy.instance1"); 128 auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.dummy.instance1");
125 DummyResource resource("org.kde.dummy.instance1", pipeline); 129 DummyResource resource("org.kde.dummy.instance1", pipeline);
@@ -191,6 +195,12 @@ private Q_SLOTS:
191 Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); 195 Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location);
192 } 196 }
193 } 197 }
198
199 //This allows to run individual parts without doing a cleanup, but still cleaning up normally
200 void testCleanupForCompleteTest()
201 {
202 DummyResource::removeFromDisk("org.kde.dummy.instance1");
203 }
194}; 204};
195 205
196QTEST_MAIN(DummyResourceBenchmark) 206QTEST_MAIN(DummyResourceBenchmark)