summaryrefslogtreecommitdiffstats
path: root/tests/mailquerybenchmark.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-16 14:55:20 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-21 09:02:21 +0200
commit237b9ae4113e7a9f489632296941becb71afdb45 (patch)
tree01cde58f495944f01cad9d282391d4efd2897141 /tests/mailquerybenchmark.cpp
parent95d11bf0be98a4e3c08502fe23417b800233ce14 (diff)
downloadsink-237b9ae4113e7a9f489632296941becb71afdb45.tar.gz
sink-237b9ae4113e7a9f489632296941becb71afdb45.zip
Refactor how the storage is used.
This is the initial refactoring to improve how we deal with the storage. It does a couple of things: * Rename Sink::Storage to Sink::Storage::DataStore to free up the Sink::Storage namespace * Introduce a Sink::ResourceContext to have a single object that can be passed around containing everything that is necessary to operate on a resource. This is a lot better than the multiple separate parameters that we used to pass around all over the place, while still allowing for dependency injection for tests. * Tie storage access together using the new EntityStore that directly works with ApplicationDomainTypes. This gives us a central place where main storage, indexes and buffer adaptors are tied together, which will also give us a place to implement external indexes, such as a fulltextindex using xapian. * Use ApplicationDomainTypes as the default way to pass around entities. Instead of using various ways to pass around entities (buffers, buffer adaptors, ApplicationDomainTypes), only use a single way. The old approach was confusing, and was only done as: * optimization; really shouldn't be necessary and otherwise I'm sure we can find better ways to optimize ApplicationDomainType itself. * a way to account for entities that have multiple buffers, a concept that I no longer deem relevant. While this commit does the bulk of the work to get there, the following commits will refactor more stuff to get things back to normal.
Diffstat (limited to 'tests/mailquerybenchmark.cpp')
-rw-r--r--tests/mailquerybenchmark.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/tests/mailquerybenchmark.cpp b/tests/mailquerybenchmark.cpp
index 1d96819..c44b9f6 100644
--- a/tests/mailquerybenchmark.cpp
+++ b/tests/mailquerybenchmark.cpp
@@ -62,8 +62,7 @@ class MailQueryBenchmark : public QObject
62 { 62 {
63 TestResource::removeFromDisk(resourceIdentifier); 63 TestResource::removeFromDisk(resourceIdentifier);
64 64
65 auto pipeline = QSharedPointer<Sink::Pipeline>::create(resourceIdentifier); 65 auto pipeline = QSharedPointer<Sink::Pipeline>::create(Sink::ResourceContext{resourceIdentifier, "test"});
66 pipeline->setResourceType("test");
67 66
68 auto indexer = QSharedPointer<DefaultIndexUpdater<Mail>>::create(); 67 auto indexer = QSharedPointer<DefaultIndexUpdater<Mail>>::create();
69 68
@@ -94,10 +93,10 @@ class MailQueryBenchmark : public QObject
94 // Benchmark 93 // Benchmark
95 QTime time; 94 QTime time;
96 time.start(); 95 time.start();
97
98 auto resultSet = QSharedPointer<Sink::ResultProvider<Mail::Ptr>>::create(); 96 auto resultSet = QSharedPointer<Sink::ResultProvider<Mail::Ptr>>::create();
99 auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); 97 Sink::ResourceContext context{resourceIdentifier, "test"};
100 TestMailResourceFacade facade(resourceIdentifier, resourceAccess); 98 context.mResourceAccess = QSharedPointer<TestResourceAccess>::create();
99 TestMailResourceFacade facade(context);
101 100
102 auto ret = facade.load(query); 101 auto ret = facade.load(query);
103 ret.first.exec().waitForFinished(); 102 ret.first.exec().waitForFinished();
@@ -115,7 +114,7 @@ class MailQueryBenchmark : public QObject
115 const auto finalRss = getCurrentRSS(); 114 const auto finalRss = getCurrentRSS();
116 const auto rssGrowth = finalRss - startingRss; 115 const auto rssGrowth = finalRss - startingRss;
117 // Since the database is memory mapped it is attributted to the resident set size. 116 // Since the database is memory mapped it is attributted to the resident set size.
118 const auto rssWithoutDb = finalRss - Sink::Storage(Sink::storageLocation(), resourceIdentifier, Sink::Storage::ReadWrite).diskUsage(); 117 const auto rssWithoutDb = finalRss - Sink::Storage::DataStore(Sink::storageLocation(), resourceIdentifier, Sink::Storage::DataStore::ReadWrite).diskUsage();
119 const auto peakRss = getPeakRSS(); 118 const auto peakRss = getPeakRSS();
120 // How much peak deviates from final rss in percent (should be around 0) 119 // How much peak deviates from final rss in percent (should be around 0)
121 const auto percentageRssError = static_cast<double>(peakRss - finalRss) * 100.0 / static_cast<double>(finalRss); 120 const auto percentageRssError = static_cast<double>(peakRss - finalRss) * 100.0 / static_cast<double>(finalRss);