diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-03 09:01:05 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-03 09:01:05 +0100 |
commit | 4d9746c828558c9f872e0aed52442863affb25d5 (patch) | |
tree | 507d7c2ba67f47d3cbbcf01a722236ff1b48426b /tests/mailquerybenchmark.cpp | |
parent | 9cea920b7dd51867a0be0fed2f461b6be73c103e (diff) | |
download | sink-4d9746c828558c9f872e0aed52442863affb25d5.tar.gz sink-4d9746c828558c9f872e0aed52442863affb25d5.zip |
Fromatted the whole codebase with clang-format.
clang-format -i */**{.cpp,.h}
Diffstat (limited to 'tests/mailquerybenchmark.cpp')
-rw-r--r-- | tests/mailquerybenchmark.cpp | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/tests/mailquerybenchmark.cpp b/tests/mailquerybenchmark.cpp index ea919ac..6b93863 100644 --- a/tests/mailquerybenchmark.cpp +++ b/tests/mailquerybenchmark.cpp | |||
@@ -61,9 +61,9 @@ class MailQueryBenchmark : public QObject | |||
61 | auto pipeline = QSharedPointer<Sink::Pipeline>::create(resourceIdentifier); | 61 | auto pipeline = QSharedPointer<Sink::Pipeline>::create(resourceIdentifier); |
62 | 62 | ||
63 | auto mailFactory = QSharedPointer<TestMailAdaptorFactory>::create(); | 63 | auto mailFactory = QSharedPointer<TestMailAdaptorFactory>::create(); |
64 | auto indexer = QSharedPointer<DefaultIndexUpdater<Sink::ApplicationDomain::Mail> >::create(); | 64 | auto indexer = QSharedPointer<DefaultIndexUpdater<Sink::ApplicationDomain::Mail>>::create(); |
65 | 65 | ||
66 | pipeline->setPreprocessors("mail", QVector<Sink::Preprocessor*>() << indexer.data()); | 66 | pipeline->setPreprocessors("mail", QVector<Sink::Preprocessor *>() << indexer.data()); |
67 | pipeline->setAdaptorFactory("mail", mailFactory); | 67 | pipeline->setAdaptorFactory("mail", mailFactory); |
68 | 68 | ||
69 | auto domainTypeAdaptorFactory = QSharedPointer<TestMailAdaptorFactory>::create(); | 69 | auto domainTypeAdaptorFactory = QSharedPointer<TestMailAdaptorFactory>::create(); |
@@ -88,11 +88,11 @@ class MailQueryBenchmark : public QObject | |||
88 | const auto startingRss = getCurrentRSS(); | 88 | const auto startingRss = getCurrentRSS(); |
89 | 89 | ||
90 | 90 | ||
91 | //Benchmark | 91 | // Benchmark |
92 | QTime time; | 92 | QTime time; |
93 | time.start(); | 93 | time.start(); |
94 | 94 | ||
95 | auto resultSet = QSharedPointer<Sink::ResultProvider<Sink::ApplicationDomain::Mail::Ptr> >::create(); | 95 | auto resultSet = QSharedPointer<Sink::ResultProvider<Sink::ApplicationDomain::Mail::Ptr>>::create(); |
96 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); | 96 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); |
97 | TestMailResourceFacade facade(resourceIdentifier, resourceAccess); | 97 | TestMailResourceFacade facade(resourceIdentifier, resourceAccess); |
98 | 98 | ||
@@ -100,13 +100,9 @@ class MailQueryBenchmark : public QObject | |||
100 | ret.first.exec().waitForFinished(); | 100 | ret.first.exec().waitForFinished(); |
101 | auto emitter = ret.second; | 101 | auto emitter = ret.second; |
102 | QList<Sink::ApplicationDomain::Mail::Ptr> list; | 102 | QList<Sink::ApplicationDomain::Mail::Ptr> list; |
103 | emitter->onAdded([&list](const Sink::ApplicationDomain::Mail::Ptr &mail) { | 103 | emitter->onAdded([&list](const Sink::ApplicationDomain::Mail::Ptr &mail) { list << mail; }); |
104 | list << mail; | ||
105 | }); | ||
106 | bool done = false; | 104 | bool done = false; |
107 | emitter->onInitialResultSetComplete([&done](const Sink::ApplicationDomain::Mail::Ptr &mail) { | 105 | emitter->onInitialResultSetComplete([&done](const Sink::ApplicationDomain::Mail::Ptr &mail) { done = true; }); |
108 | done = true; | ||
109 | }); | ||
110 | emitter->fetch(Sink::ApplicationDomain::Mail::Ptr()); | 106 | emitter->fetch(Sink::ApplicationDomain::Mail::Ptr()); |
111 | QTRY_VERIFY(done); | 107 | QTRY_VERIFY(done); |
112 | QCOMPARE(list.size(), query.limit); | 108 | QCOMPARE(list.size(), query.limit); |
@@ -115,32 +111,32 @@ class MailQueryBenchmark : public QObject | |||
115 | 111 | ||
116 | const auto finalRss = getCurrentRSS(); | 112 | const auto finalRss = getCurrentRSS(); |
117 | const auto rssGrowth = finalRss - startingRss; | 113 | const auto rssGrowth = finalRss - startingRss; |
118 | //Since the database is memory mapped it is attributted to the resident set size. | 114 | // Since the database is memory mapped it is attributted to the resident set size. |
119 | const auto rssWithoutDb = finalRss - Sink::Storage(Sink::storageLocation(), resourceIdentifier, Sink::Storage::ReadWrite).diskUsage(); | 115 | const auto rssWithoutDb = finalRss - Sink::Storage(Sink::storageLocation(), resourceIdentifier, Sink::Storage::ReadWrite).diskUsage(); |
120 | const auto peakRss = getPeakRSS(); | 116 | const auto peakRss = getPeakRSS(); |
121 | //How much peak deviates from final rss in percent (should be around 0) | 117 | // How much peak deviates from final rss in percent (should be around 0) |
122 | const auto percentageRssError = static_cast<double>(peakRss - finalRss)*100.0/static_cast<double>(finalRss); | 118 | const auto percentageRssError = static_cast<double>(peakRss - finalRss) * 100.0 / static_cast<double>(finalRss); |
123 | auto rssGrowthPerEntity = rssGrowth/count; | 119 | auto rssGrowthPerEntity = rssGrowth / count; |
124 | 120 | ||
125 | std::cout << "Loaded " << list.size() << " results." << std::endl; | 121 | std::cout << "Loaded " << list.size() << " results." << std::endl; |
126 | std::cout << "The query took [ms]: " << elapsed << std::endl; | 122 | std::cout << "The query took [ms]: " << elapsed << std::endl; |
127 | std::cout << "Current Rss usage [kb]: " << finalRss/1024 << std::endl; | 123 | std::cout << "Current Rss usage [kb]: " << finalRss / 1024 << std::endl; |
128 | std::cout << "Peak Rss usage [kb]: " << peakRss/1024 << std::endl; | 124 | std::cout << "Peak Rss usage [kb]: " << peakRss / 1024 << std::endl; |
129 | std::cout << "Rss growth [kb]: " << rssGrowth/1024 << std::endl; | 125 | std::cout << "Rss growth [kb]: " << rssGrowth / 1024 << std::endl; |
130 | std::cout << "Rss growth per entity [byte]: " << rssGrowthPerEntity << std::endl; | 126 | std::cout << "Rss growth per entity [byte]: " << rssGrowthPerEntity << std::endl; |
131 | std::cout << "Rss without db [kb]: " << rssWithoutDb/1024 << std::endl; | 127 | std::cout << "Rss without db [kb]: " << rssWithoutDb / 1024 << std::endl; |
132 | std::cout << "Percentage error: " << percentageRssError << std::endl; | 128 | std::cout << "Percentage error: " << percentageRssError << std::endl; |
133 | 129 | ||
134 | HAWD::Dataset dataset("mail_query", mHawdState); | 130 | HAWD::Dataset dataset("mail_query", mHawdState); |
135 | HAWD::Dataset::Row row = dataset.row(); | 131 | HAWD::Dataset::Row row = dataset.row(); |
136 | row.setValue("rows", list.size()); | 132 | row.setValue("rows", list.size()); |
137 | row.setValue("queryResultPerMs", (qreal)list.size()/elapsed); | 133 | row.setValue("queryResultPerMs", (qreal)list.size() / elapsed); |
138 | dataset.insertRow(row); | 134 | dataset.insertRow(row); |
139 | HAWD::Formatter::print(dataset); | 135 | HAWD::Formatter::print(dataset); |
140 | 136 | ||
141 | QVERIFY(percentageRssError < 10); | 137 | QVERIFY(percentageRssError < 10); |
142 | //TODO This is much more than it should it seems, although adding the attachment results in pretty exactly a 1k increase, | 138 | // TODO This is much more than it should it seems, although adding the attachment results in pretty exactly a 1k increase, |
143 | //so it doesn't look like that memory is being duplicated. | 139 | // so it doesn't look like that memory is being duplicated. |
144 | QVERIFY(rssGrowthPerEntity < 3300); | 140 | QVERIFY(rssGrowthPerEntity < 3300); |
145 | 141 | ||
146 | // Print memory layout, RSS is what is in memory | 142 | // Print memory layout, RSS is what is in memory |
@@ -159,7 +155,9 @@ private slots: | |||
159 | { | 155 | { |
160 | Sink::Query query; | 156 | Sink::Query query; |
161 | query.liveQuery = false; | 157 | query.liveQuery = false; |
162 | query.requestedProperties << "uid" << "subject" << "date"; | 158 | query.requestedProperties << "uid" |
159 | << "subject" | ||
160 | << "date"; | ||
163 | query.sortProperty = "date"; | 161 | query.sortProperty = "date"; |
164 | query.propertyFilter.insert("folder", "folder1"); | 162 | query.propertyFilter.insert("folder", "folder1"); |
165 | query.limit = 1000; | 163 | query.limit = 1000; |
@@ -167,7 +165,6 @@ private slots: | |||
167 | populateDatabase(50000); | 165 | populateDatabase(50000); |
168 | testLoad(query, 50000); | 166 | testLoad(query, 50000); |
169 | } | 167 | } |
170 | |||
171 | }; | 168 | }; |
172 | 169 | ||
173 | QTEST_MAIN(MailQueryBenchmark) | 170 | QTEST_MAIN(MailQueryBenchmark) |