diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-06 00:56:30 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-06 00:56:30 +0200 |
commit | b7873e621ef45badaa70e2d285998c486920df4a (patch) | |
tree | 8439e8881504a231d2c3355ce0ccebd775592140 | |
parent | ffdbd257bc4b13132b10f60d9ab70759e1f259bd (diff) | |
download | sink-b7873e621ef45badaa70e2d285998c486920df4a.tar.gz sink-b7873e621ef45badaa70e2d285998c486920df4a.zip |
Benchmark for in-process writing.
To measure overhead of the communication to the separate process.
-rw-r--r-- | tests/dummyresourcebenchmark.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp index 01d9ca4..7375ff8 100644 --- a/tests/dummyresourcebenchmark.cpp +++ b/tests/dummyresourcebenchmark.cpp | |||
@@ -7,6 +7,12 @@ | |||
7 | #include "commands.h" | 7 | #include "commands.h" |
8 | #include "entitybuffer.h" | 8 | #include "entitybuffer.h" |
9 | 9 | ||
10 | #include "event_generated.h" | ||
11 | #include "entity_generated.h" | ||
12 | #include "metadata_generated.h" | ||
13 | #include "createentity_generated.h" | ||
14 | #include "dummyresource/resourcefactory.h" | ||
15 | |||
10 | static void removeFromDisk(const QString &name) | 16 | static void removeFromDisk(const QString &name) |
11 | { | 17 | { |
12 | Akonadi2::Storage store(Akonadi2::Store::storageLocation(), name, Akonadi2::Storage::ReadWrite); | 18 | Akonadi2::Storage store(Akonadi2::Store::storageLocation(), name, Akonadi2::Storage::ReadWrite); |
@@ -79,6 +85,65 @@ private Q_SLOTS: | |||
79 | qDebug() << "All processed: " << allProcessedTime << "/sec " << num*1000/allProcessedTime; | 85 | qDebug() << "All processed: " << allProcessedTime << "/sec " << num*1000/allProcessedTime; |
80 | qDebug() << "Query Time: " << time.elapsed() << "/sec " << num*1000/time.elapsed(); | 86 | qDebug() << "Query Time: " << time.elapsed() << "/sec " << num*1000/time.elapsed(); |
81 | } | 87 | } |
88 | |||
89 | void testWriteInProcess() | ||
90 | { | ||
91 | QTime time; | ||
92 | time.start(); | ||
93 | int num = 10000; | ||
94 | |||
95 | //Actual test | ||
96 | Akonadi2::Pipeline pipeline("org.kde.dummy"); | ||
97 | QSignalSpy revisionSpy(&pipeline, SIGNAL(revisionUpdated())); | ||
98 | DummyResource resource; | ||
99 | resource.configurePipeline(&pipeline); | ||
100 | |||
101 | for (int i = 0; i < num; i++) { | ||
102 | flatbuffers::FlatBufferBuilder eventFbb; | ||
103 | eventFbb.Clear(); | ||
104 | { | ||
105 | auto summary = eventFbb.CreateString("summary"); | ||
106 | Akonadi2::Domain::Buffer::EventBuilder eventBuilder(eventFbb); | ||
107 | eventBuilder.add_summary(summary); | ||
108 | auto eventLocation = eventBuilder.Finish(); | ||
109 | Akonadi2::Domain::Buffer::FinishEventBuffer(eventFbb, eventLocation); | ||
110 | } | ||
111 | |||
112 | flatbuffers::FlatBufferBuilder localFbb; | ||
113 | { | ||
114 | auto uid = localFbb.CreateString("testuid"); | ||
115 | auto localBuilder = Akonadi2::Domain::Buffer::EventBuilder(localFbb); | ||
116 | localBuilder.add_uid(uid); | ||
117 | auto location = localBuilder.Finish(); | ||
118 | Akonadi2::Domain::Buffer::FinishEventBuffer(localFbb, location); | ||
119 | } | ||
120 | |||
121 | flatbuffers::FlatBufferBuilder entityFbb; | ||
122 | Akonadi2::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); | ||
123 | |||
124 | flatbuffers::FlatBufferBuilder fbb; | ||
125 | auto type = fbb.CreateString(Akonadi2::Domain::getTypeName<Akonadi2::Domain::Event>().toStdString().data()); | ||
126 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); | ||
127 | Akonadi2::Commands::CreateEntityBuilder builder(fbb); | ||
128 | builder.add_domainType(type); | ||
129 | builder.add_delta(delta); | ||
130 | auto location = builder.Finish(); | ||
131 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | ||
132 | |||
133 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | ||
134 | |||
135 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command, command.size(), &pipeline); | ||
136 | } | ||
137 | auto appendTime = time.elapsed(); | ||
138 | |||
139 | //Wait until all messages have been processed | ||
140 | resource.processAllMessages().exec().waitForFinished(); | ||
141 | |||
142 | auto allProcessedTime = time.elapsed(); | ||
143 | |||
144 | qDebug() << "Append to messagequeue " << appendTime; | ||
145 | qDebug() << "All processed: " << allProcessedTime << "/sec " << num*1000/allProcessedTime; | ||
146 | } | ||
82 | }; | 147 | }; |
83 | 148 | ||
84 | QTEST_MAIN(DummyResourceBenchmark) | 149 | QTEST_MAIN(DummyResourceBenchmark) |