summaryrefslogtreecommitdiffstats
path: root/tests/genericfacadebenchmark.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-22 09:23:27 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-22 09:23:27 +0100
commit8e6671fe6d6519f1fecf37338a3263a5b88a00d1 (patch)
tree7ae0f08aef08566176611476bea8a85ae2707025 /tests/genericfacadebenchmark.cpp
parent042d8fb10552d0bcc92647338d9d763357f35880 (diff)
downloadsink-8e6671fe6d6519f1fecf37338a3263a5b88a00d1.tar.gz
sink-8e6671fe6d6519f1fecf37338a3263a5b88a00d1.zip
An automated test that keeps memory usage in check.
And ensures we scale linearly with the number of entities.
Diffstat (limited to 'tests/genericfacadebenchmark.cpp')
-rw-r--r--tests/genericfacadebenchmark.cpp79
1 files changed, 0 insertions, 79 deletions
diff --git a/tests/genericfacadebenchmark.cpp b/tests/genericfacadebenchmark.cpp
deleted file mode 100644
index 703acd1..0000000
--- a/tests/genericfacadebenchmark.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
1#include <QtTest>
2
3#include <QString>
4
5#include "testimplementations.h"
6
7#include <common/facade.h>
8#include <common/domainadaptor.h>
9#include <common/resultprovider.h>
10#include <common/synclistresult.h>
11#include <common/definitions.h>
12
13#include "event_generated.h"
14
15
16
17/**
18 * Benchmark read performance of the generic facade implementation.
19 */
20class GenericFacadeBenchmark : public QObject
21{
22 Q_OBJECT
23private Q_SLOTS:
24
25 void initTestCase()
26 {
27 Akonadi2::Storage store(Akonadi2::storageLocation(), "identifier", Akonadi2::Storage::ReadWrite);
28 store.removeFromDisk();
29 }
30
31 void testLoad()
32 {
33 const QByteArray identifier = "identifier";
34 const int count = 100000;
35
36 //Setup
37 auto domainTypeAdaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create();
38 {
39 Akonadi2::Storage storage(Akonadi2::storageLocation(), identifier, Akonadi2::Storage::ReadWrite);
40 auto transaction = storage.createTransaction(Akonadi2::Storage::ReadWrite);
41 auto db = transaction.openDatabase();
42 for (int i = 0; i < count; i++) {
43 auto domainObject = Akonadi2::ApplicationDomain::Event::Ptr::create();
44 domainObject->setProperty("uid", "uid");
45 domainObject->setProperty("summary", "summary");
46
47 flatbuffers::FlatBufferBuilder fbb;
48 domainTypeAdaptorFactory->createBuffer(*domainObject, fbb);
49 db.write(QString::number(i).toLatin1(), QByteArray::fromRawData(reinterpret_cast<const char*>(fbb.GetBufferPointer()), fbb.GetSize()));
50 }
51 }
52
53 Akonadi2::Query query;
54 query.liveQuery = false;
55
56 //Benchmark
57 QBENCHMARK {
58 auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create();
59 auto resourceAccess = QSharedPointer<TestResourceAccess>::create();
60 TestResourceFacade facade(identifier, resourceAccess);
61
62 async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter());
63
64 facade.load(query, *resultSet).exec().waitForFinished();
65 resultSet->initialResultSetComplete();
66
67 //We have to wait for the events that deliver the results to be processed by the eventloop
68 result.exec();
69
70 QCOMPARE(result.size(), count);
71 }
72
73 // Print memory layout, RSS is what is in memory
74 // std::system("exec pmap -x \"$PPID\"");
75 }
76};
77
78QTEST_MAIN(GenericFacadeBenchmark)
79#include "genericfacadebenchmark.moc"