From c00d5fb305abff370f869dec0e9404f8a4a5646b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 7 Apr 2015 12:50:07 +0200 Subject: 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. --- tests/CMakeLists.txt | 1 + tests/dummyresourcebenchmark.cpp | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8257c8a..a38471f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,6 +2,7 @@ add_subdirectory(hawd) set(CMAKE_AUTOMOC ON) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/hawd) +include_directories (${CMAKE_CURRENT_BINARY_DIR}/../dummyresource) generate_flatbuffers(calendar) 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 @@ #include #include "dummyresource/resourcefactory.h" +#include "dummyresource/domainadaptor.h" #include "clientapi.h" #include "commands.h" #include "entitybuffer.h" @@ -11,7 +12,6 @@ #include "entity_generated.h" #include "metadata_generated.h" #include "createentity_generated.h" -#include "dummyresource/resourcefactory.h" static void removeFromDisk(const QString &name) { @@ -144,6 +144,26 @@ private Q_SLOTS: qDebug() << "Append to messagequeue " << appendTime; qDebug() << "All processed: " << allProcessedTime << "/sec " << num*1000/allProcessedTime; } + void testCreateCommand() + { + Akonadi2::Domain::Event event; + + QBENCHMARK { + auto mFactory = new DummyEventAdaptorFactory; + static flatbuffers::FlatBufferBuilder entityFbb; + entityFbb.Clear(); + mFactory->createBuffer(event, entityFbb); + + static flatbuffers::FlatBufferBuilder fbb; + fbb.Clear(); + //This is the resource buffer type and not the domain type + auto type = fbb.CreateString("event"); + // auto delta = fbb.CreateVector(entityFbb.GetBufferPointer(), entityFbb.GetSize()); + auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); + auto location = Akonadi2::Commands::CreateCreateEntity(fbb, type, delta); + Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); + } + } }; QTEST_MAIN(DummyResourceBenchmark) -- cgit v1.2.3