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