diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-01-27 23:48:46 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-01-27 23:48:46 +0100 |
commit | de00275898e5cf5f9bbc829f7e4059b7afa02e2a (patch) | |
tree | 215db576bd2356075fb505fbe9940b204e67c61e | |
parent | 142bf3d8bc6569a432e065e851f026a46e9595ed (diff) | |
download | sink-de00275898e5cf5f9bbc829f7e4059b7afa02e2a.tar.gz sink-de00275898e5cf5f9bbc829f7e4059b7afa02e2a.zip |
DummyResourceBenchmark
-rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/dummyresourcebenchmark.cpp | 85 |
2 files changed, 87 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7ef4113..8257c8a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt | |||
@@ -20,7 +20,9 @@ manual_tests ( | |||
20 | domainadaptortest | 20 | domainadaptortest |
21 | messagequeuetest | 21 | messagequeuetest |
22 | indextest | 22 | indextest |
23 | dummyresourcebenchmark | ||
23 | ) | 24 | ) |
24 | 25 | ||
25 | target_link_libraries(dummyresourcetest akonadi2_resource_dummy) | 26 | target_link_libraries(dummyresourcetest akonadi2_resource_dummy) |
27 | target_link_libraries(dummyresourcebenchmark akonadi2_resource_dummy) | ||
26 | 28 | ||
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp new file mode 100644 index 0000000..01d9ca4 --- /dev/null +++ b/tests/dummyresourcebenchmark.cpp | |||
@@ -0,0 +1,85 @@ | |||
1 | #include <QtTest> | ||
2 | |||
3 | #include <QString> | ||
4 | |||
5 | #include "dummyresource/resourcefactory.h" | ||
6 | #include "clientapi.h" | ||
7 | #include "commands.h" | ||
8 | #include "entitybuffer.h" | ||
9 | |||
10 | static void removeFromDisk(const QString &name) | ||
11 | { | ||
12 | Akonadi2::Storage store(Akonadi2::Store::storageLocation(), name, Akonadi2::Storage::ReadWrite); | ||
13 | store.removeFromDisk(); | ||
14 | } | ||
15 | |||
16 | class DummyResourceBenchmark : public QObject | ||
17 | { | ||
18 | Q_OBJECT | ||
19 | private Q_SLOTS: | ||
20 | void initTestCase() | ||
21 | { | ||
22 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | ||
23 | QVERIFY(factory); | ||
24 | removeFromDisk("org.kde.dummy"); | ||
25 | removeFromDisk("org.kde.dummy.userqueue"); | ||
26 | removeFromDisk("org.kde.dummy.synchronizerqueue"); | ||
27 | removeFromDisk("org.kde.dummy.index.uid"); | ||
28 | } | ||
29 | |||
30 | void cleanup() | ||
31 | { | ||
32 | removeFromDisk("org.kde.dummy"); | ||
33 | removeFromDisk("org.kde.dummy.userqueue"); | ||
34 | removeFromDisk("org.kde.dummy.synchronizerqueue"); | ||
35 | removeFromDisk("org.kde.dummy.index.uid"); | ||
36 | } | ||
37 | |||
38 | void testWriteToFacadeAndQueryByUid() | ||
39 | { | ||
40 | QTime time; | ||
41 | time.start(); | ||
42 | int num = 10000; | ||
43 | for (int i = 0; i < num; i++) { | ||
44 | Akonadi2::Domain::Event event; | ||
45 | event.setProperty("uid", "testuid"); | ||
46 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); | ||
47 | event.setProperty("summary", "summaryValue"); | ||
48 | Akonadi2::Store::create<Akonadi2::Domain::Event>(event, "org.kde.dummy"); | ||
49 | } | ||
50 | auto appendTime = time.elapsed(); | ||
51 | |||
52 | //Ensure everything is processed | ||
53 | { | ||
54 | Akonadi2::Query query; | ||
55 | query.resources << "org.kde.dummy"; | ||
56 | query.syncOnDemand = false; | ||
57 | query.processAll = true; | ||
58 | |||
59 | query.propertyFilter.insert("uid", "nonexistantuid"); | ||
60 | async::SyncListResult<Akonadi2::Domain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::Domain::Event>(query)); | ||
61 | result.exec(); | ||
62 | } | ||
63 | auto allProcessedTime = time.elapsed(); | ||
64 | |||
65 | //Measure query | ||
66 | { | ||
67 | time.start(); | ||
68 | Akonadi2::Query query; | ||
69 | query.resources << "org.kde.dummy"; | ||
70 | query.syncOnDemand = false; | ||
71 | query.processAll = false; | ||
72 | |||
73 | query.propertyFilter.insert("uid", "testuid"); | ||
74 | async::SyncListResult<Akonadi2::Domain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::Domain::Event>(query)); | ||
75 | result.exec(); | ||
76 | QCOMPARE(result.size(), num); | ||
77 | } | ||
78 | qDebug() << "Append to messagequeue " << appendTime; | ||
79 | qDebug() << "All processed: " << allProcessedTime << "/sec " << num*1000/allProcessedTime; | ||
80 | qDebug() << "Query Time: " << time.elapsed() << "/sec " << num*1000/time.elapsed(); | ||
81 | } | ||
82 | }; | ||
83 | |||
84 | QTEST_MAIN(DummyResourceBenchmark) | ||
85 | #include "dummyresourcebenchmark.moc" | ||