diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-09 19:46:27 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-09 19:46:27 +0200 |
commit | 7a1460b35f6282f76150d8aa504930fe196ef2aa (patch) | |
tree | e2863f5323a5d065e27dc960fbeefe2454a2caa2 | |
parent | 4f1afa39bec38ea38820115e1bbabf4506c2d45c (diff) | |
download | sink-7a1460b35f6282f76150d8aa504930fe196ef2aa.tar.gz sink-7a1460b35f6282f76150d8aa504930fe196ef2aa.zip |
Only measure appending, not creating the buffer.
-rw-r--r-- | tests/dummyresourcebenchmark.cpp | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp index ea3f556..d83cb70 100644 --- a/tests/dummyresourcebenchmark.cpp +++ b/tests/dummyresourcebenchmark.cpp | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "entity_generated.h" | 12 | #include "entity_generated.h" |
13 | #include "metadata_generated.h" | 13 | #include "metadata_generated.h" |
14 | #include "createentity_generated.h" | 14 | #include "createentity_generated.h" |
15 | #include <iostream> | ||
15 | 16 | ||
16 | static void removeFromDisk(const QString &name) | 17 | static void removeFromDisk(const QString &name) |
17 | { | 18 | { |
@@ -92,46 +93,45 @@ private Q_SLOTS: | |||
92 | time.start(); | 93 | time.start(); |
93 | int num = 10000; | 94 | int num = 10000; |
94 | 95 | ||
95 | //Actual test | ||
96 | Akonadi2::Pipeline pipeline("org.kde.dummy"); | 96 | Akonadi2::Pipeline pipeline("org.kde.dummy"); |
97 | QSignalSpy revisionSpy(&pipeline, SIGNAL(revisionUpdated())); | 97 | QSignalSpy revisionSpy(&pipeline, SIGNAL(revisionUpdated())); |
98 | DummyResource resource; | 98 | DummyResource resource; |
99 | resource.configurePipeline(&pipeline); | 99 | resource.configurePipeline(&pipeline); |
100 | 100 | ||
101 | for (int i = 0; i < num; i++) { | 101 | flatbuffers::FlatBufferBuilder eventFbb; |
102 | flatbuffers::FlatBufferBuilder eventFbb; | 102 | eventFbb.Clear(); |
103 | eventFbb.Clear(); | 103 | { |
104 | { | 104 | auto summary = eventFbb.CreateString("summary"); |
105 | auto summary = eventFbb.CreateString("summary"); | 105 | Akonadi2::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb); |
106 | Akonadi2::Domain::Buffer::EventBuilder eventBuilder(eventFbb); | 106 | eventBuilder.add_summary(summary); |
107 | eventBuilder.add_summary(summary); | 107 | auto eventLocation = eventBuilder.Finish(); |
108 | auto eventLocation = eventBuilder.Finish(); | 108 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation); |
109 | Akonadi2::Domain::Buffer::FinishEventBuffer(eventFbb, eventLocation); | 109 | } |
110 | } | 110 | |
111 | 111 | flatbuffers::FlatBufferBuilder localFbb; | |
112 | flatbuffers::FlatBufferBuilder localFbb; | 112 | { |
113 | { | 113 | auto uid = localFbb.CreateString("testuid"); |
114 | auto uid = localFbb.CreateString("testuid"); | 114 | auto localBuilder = Akonadi2::ApplicationDomain::Buffer::EventBuilder(localFbb); |
115 | auto localBuilder = Akonadi2::Domain::Buffer::EventBuilder(localFbb); | 115 | localBuilder.add_uid(uid); |
116 | localBuilder.add_uid(uid); | 116 | auto location = localBuilder.Finish(); |
117 | auto location = localBuilder.Finish(); | 117 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); |
118 | Akonadi2::Domain::Buffer::FinishEventBuffer(localFbb, location); | 118 | } |
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 | 119 | ||
133 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | 120 | flatbuffers::FlatBufferBuilder entityFbb; |
121 | Akonadi2::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); | ||
134 | 122 | ||
123 | flatbuffers::FlatBufferBuilder fbb; | ||
124 | auto type = fbb.CreateString(Akonadi2::ApplicationDomain::getTypeName<Akonadi2::ApplicationDomain::Event>().toStdString().data()); | ||
125 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); | ||
126 | Akonadi2::Commands::CreateEntityBuilder builder(fbb); | ||
127 | builder.add_domainType(type); | ||
128 | builder.add_delta(delta); | ||
129 | auto location = builder.Finish(); | ||
130 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | ||
131 | |||
132 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | ||
133 | |||
134 | for (int i = 0; i < num; i++) { | ||
135 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command, command.size(), &pipeline); | 135 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command, command.size(), &pipeline); |
136 | } | 136 | } |
137 | auto appendTime = time.elapsed(); | 137 | auto appendTime = time.elapsed(); |
@@ -141,9 +141,10 @@ private Q_SLOTS: | |||
141 | 141 | ||
142 | auto allProcessedTime = time.elapsed(); | 142 | auto allProcessedTime = time.elapsed(); |
143 | 143 | ||
144 | qDebug() << "Append to messagequeue " << appendTime; | 144 | std::cout << "Append to messagequeue " << appendTime << std::endl; |
145 | qDebug() << "All processed: " << allProcessedTime << "/sec " << num*1000/allProcessedTime; | 145 | std::cout << "All processed: " << allProcessedTime << "/sec " << num*1000/allProcessedTime << std::endl; |
146 | } | 146 | } |
147 | |||
147 | void testCreateCommand() | 148 | void testCreateCommand() |
148 | { | 149 | { |
149 | Akonadi2::ApplicationDomain::Event event; | 150 | Akonadi2::ApplicationDomain::Event event; |