diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-09-27 16:15:44 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-09-27 16:15:44 +0200 |
commit | 5830d7e0d1d35494823f5fa61a4871b8d9df1c9d (patch) | |
tree | 1383d9b6ad926a97ee8376175c6bee01182dc096 /tests/mailquerybenchmark.cpp | |
parent | 529db49c496f4f668cec3f7c59d2d0ec78c50c9a (diff) | |
download | sink-5830d7e0d1d35494823f5fa61a4871b8d9df1c9d.tar.gz sink-5830d7e0d1d35494823f5fa61a4871b8d9df1c9d.zip |
Use the Query::filter api.
Diffstat (limited to 'tests/mailquerybenchmark.cpp')
-rw-r--r-- | tests/mailquerybenchmark.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/tests/mailquerybenchmark.cpp b/tests/mailquerybenchmark.cpp index 450955f..1d96819 100644 --- a/tests/mailquerybenchmark.cpp +++ b/tests/mailquerybenchmark.cpp | |||
@@ -45,6 +45,9 @@ | |||
45 | #include "createentity_generated.h" | 45 | #include "createentity_generated.h" |
46 | #include "getrssusage.h" | 46 | #include "getrssusage.h" |
47 | 47 | ||
48 | using namespace Sink; | ||
49 | using namespace Sink::ApplicationDomain; | ||
50 | |||
48 | /** | 51 | /** |
49 | * Benchmark mail query performance. | 52 | * Benchmark mail query performance. |
50 | */ | 53 | */ |
@@ -62,7 +65,7 @@ class MailQueryBenchmark : public QObject | |||
62 | auto pipeline = QSharedPointer<Sink::Pipeline>::create(resourceIdentifier); | 65 | auto pipeline = QSharedPointer<Sink::Pipeline>::create(resourceIdentifier); |
63 | pipeline->setResourceType("test"); | 66 | pipeline->setResourceType("test"); |
64 | 67 | ||
65 | auto indexer = QSharedPointer<DefaultIndexUpdater<Sink::ApplicationDomain::Mail>>::create(); | 68 | auto indexer = QSharedPointer<DefaultIndexUpdater<Mail>>::create(); |
66 | 69 | ||
67 | pipeline->setPreprocessors("mail", QVector<Sink::Preprocessor *>() << indexer.data()); | 70 | pipeline->setPreprocessors("mail", QVector<Sink::Preprocessor *>() << indexer.data()); |
68 | 71 | ||
@@ -71,13 +74,13 @@ class MailQueryBenchmark : public QObject | |||
71 | pipeline->startTransaction(); | 74 | pipeline->startTransaction(); |
72 | const auto date = QDateTime::currentDateTimeUtc(); | 75 | const auto date = QDateTime::currentDateTimeUtc(); |
73 | for (int i = 0; i < count; i++) { | 76 | for (int i = 0; i < count; i++) { |
74 | auto domainObject = Sink::ApplicationDomain::Mail::Ptr::create(); | 77 | auto domainObject = Mail::Ptr::create(); |
75 | domainObject->setProperty("uid", "uid"); | 78 | domainObject->setProperty("uid", "uid"); |
76 | domainObject->setProperty("subject", QString("subject%1").arg(i)); | 79 | domainObject->setProperty("subject", QString("subject%1").arg(i)); |
77 | domainObject->setProperty("date", date.addSecs(count)); | 80 | domainObject->setProperty("date", date.addSecs(count)); |
78 | domainObject->setProperty("folder", "folder1"); | 81 | domainObject->setProperty("folder", "folder1"); |
79 | // domainObject->setProperty("attachment", attachment); | 82 | // domainObject->setProperty("attachment", attachment); |
80 | const auto command = createCommand<Sink::ApplicationDomain::Mail>(*domainObject, *domainTypeAdaptorFactory); | 83 | const auto command = createCommand<Mail>(*domainObject, *domainTypeAdaptorFactory); |
81 | pipeline->newEntity(command.data(), command.size()); | 84 | pipeline->newEntity(command.data(), command.size()); |
82 | } | 85 | } |
83 | pipeline->commit(); | 86 | pipeline->commit(); |
@@ -92,18 +95,18 @@ class MailQueryBenchmark : public QObject | |||
92 | QTime time; | 95 | QTime time; |
93 | time.start(); | 96 | time.start(); |
94 | 97 | ||
95 | auto resultSet = QSharedPointer<Sink::ResultProvider<Sink::ApplicationDomain::Mail::Ptr>>::create(); | 98 | auto resultSet = QSharedPointer<Sink::ResultProvider<Mail::Ptr>>::create(); |
96 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); | 99 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); |
97 | TestMailResourceFacade facade(resourceIdentifier, resourceAccess); | 100 | TestMailResourceFacade facade(resourceIdentifier, resourceAccess); |
98 | 101 | ||
99 | auto ret = facade.load(query); | 102 | auto ret = facade.load(query); |
100 | ret.first.exec().waitForFinished(); | 103 | ret.first.exec().waitForFinished(); |
101 | auto emitter = ret.second; | 104 | auto emitter = ret.second; |
102 | QList<Sink::ApplicationDomain::Mail::Ptr> list; | 105 | QList<Mail::Ptr> list; |
103 | emitter->onAdded([&list](const Sink::ApplicationDomain::Mail::Ptr &mail) { list << mail; }); | 106 | emitter->onAdded([&list](const Mail::Ptr &mail) { list << mail; }); |
104 | bool done = false; | 107 | bool done = false; |
105 | emitter->onInitialResultSetComplete([&done](const Sink::ApplicationDomain::Mail::Ptr &mail) { done = true; }); | 108 | emitter->onInitialResultSetComplete([&done](const Mail::Ptr &mail) { done = true; }); |
106 | emitter->fetch(Sink::ApplicationDomain::Mail::Ptr()); | 109 | emitter->fetch(Mail::Ptr()); |
107 | QTRY_VERIFY(done); | 110 | QTRY_VERIFY(done); |
108 | QCOMPARE(list.size(), query.limit); | 111 | QCOMPARE(list.size(), query.limit); |
109 | 112 | ||
@@ -149,18 +152,18 @@ private slots: | |||
149 | void init() | 152 | void init() |
150 | { | 153 | { |
151 | resourceIdentifier = "sink.test.instance1"; | 154 | resourceIdentifier = "sink.test.instance1"; |
152 | Sink::AdaptorFactoryRegistry::instance().registerFactory<Sink::ApplicationDomain::Mail, TestMailAdaptorFactory>("test"); | 155 | Sink::AdaptorFactoryRegistry::instance().registerFactory<Mail, TestMailAdaptorFactory>("test"); |
153 | } | 156 | } |
154 | 157 | ||
155 | void test50k() | 158 | void test50k() |
156 | { | 159 | { |
157 | Sink::Query query; | 160 | Sink::Query query; |
158 | query.liveQuery = false; | 161 | query.liveQuery = false; |
159 | query.requestedProperties << "uid" | 162 | query.request<Mail::Uid>() |
160 | << "subject" | 163 | .request<Mail::Subject>() |
161 | << "date"; | 164 | .request<Mail::Date>(); |
162 | query.sortProperty = "date"; | 165 | query.sort<Mail::Date>(); |
163 | query += Sink::Query::PropertyFilter("folder", "folder1"); | 166 | query.filter<Mail::Folder>("folder1"); |
164 | query.limit = 1000; | 167 | query.limit = 1000; |
165 | 168 | ||
166 | populateDatabase(50000); | 169 | populateDatabase(50000); |