summaryrefslogtreecommitdiffstats
path: root/tests/dummyresourcebenchmark.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-07 12:50:07 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-07 12:50:07 +0200
commitc00d5fb305abff370f869dec0e9404f8a4a5646b (patch)
tree12794ff568d272e7326f6502727443e7928cd64c /tests/dummyresourcebenchmark.cpp
parentb7873e621ef45badaa70e2d285998c486920df4a (diff)
downloadsink-c00d5fb305abff370f869dec0e9404f8a4a5646b.tar.gz
sink-c00d5fb305abff370f869dec0e9404f8a4a5646b.zip
Use memcpy to copy tables into vectors.
Ideally we wouldn't be copying at all, and somehow cast the table to a vector. Unfortunately I haven't figured out how to do that, and this solution at least gets us from 0.065 ms to 0.028 ms in testCreateCommand.
Diffstat (limited to 'tests/dummyresourcebenchmark.cpp')
-rw-r--r--tests/dummyresourcebenchmark.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp
index 7375ff8..308a4e8 100644
--- a/tests/dummyresourcebenchmark.cpp
+++ b/tests/dummyresourcebenchmark.cpp
@@ -3,6 +3,7 @@
3#include <QString> 3#include <QString>
4 4
5#include "dummyresource/resourcefactory.h" 5#include "dummyresource/resourcefactory.h"
6#include "dummyresource/domainadaptor.h"
6#include "clientapi.h" 7#include "clientapi.h"
7#include "commands.h" 8#include "commands.h"
8#include "entitybuffer.h" 9#include "entitybuffer.h"
@@ -11,7 +12,6 @@
11#include "entity_generated.h" 12#include "entity_generated.h"
12#include "metadata_generated.h" 13#include "metadata_generated.h"
13#include "createentity_generated.h" 14#include "createentity_generated.h"
14#include "dummyresource/resourcefactory.h"
15 15
16static void removeFromDisk(const QString &name) 16static void removeFromDisk(const QString &name)
17{ 17{
@@ -144,6 +144,26 @@ private Q_SLOTS:
144 qDebug() << "Append to messagequeue " << appendTime; 144 qDebug() << "Append to messagequeue " << appendTime;
145 qDebug() << "All processed: " << allProcessedTime << "/sec " << num*1000/allProcessedTime; 145 qDebug() << "All processed: " << allProcessedTime << "/sec " << num*1000/allProcessedTime;
146 } 146 }
147 void testCreateCommand()
148 {
149 Akonadi2::Domain::Event event;
150
151 QBENCHMARK {
152 auto mFactory = new DummyEventAdaptorFactory;
153 static flatbuffers::FlatBufferBuilder entityFbb;
154 entityFbb.Clear();
155 mFactory->createBuffer(event, entityFbb);
156
157 static flatbuffers::FlatBufferBuilder fbb;
158 fbb.Clear();
159 //This is the resource buffer type and not the domain type
160 auto type = fbb.CreateString("event");
161 // auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize());
162 auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize());
163 auto location = Akonadi2::Commands::CreateCreateEntity(fbb, type, delta);
164 Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location);
165 }
166 }
147}; 167};
148 168
149QTEST_MAIN(DummyResourceBenchmark) 169QTEST_MAIN(DummyResourceBenchmark)