From 1d85b3c794b1e9b7c91b9536f79d4b469a2ffcb0 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 10 Apr 2018 14:54:53 +0200 Subject: Use the Dummy instead of Event in the benchmark to restore the attachment. --- common/domain/dummy.fbs | 4 ++++ tests/storagebenchmark.cpp | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/common/domain/dummy.fbs b/common/domain/dummy.fbs index 4b12827..8b8df4e 100644 --- a/common/domain/dummy.fbs +++ b/common/domain/dummy.fbs @@ -1,6 +1,10 @@ namespace Sink.ApplicationDomain.Buffer; table Dummy { + uid:string; + summary:string; + description:string; + attachment:[ubyte]; } root_type Dummy; diff --git a/tests/storagebenchmark.cpp b/tests/storagebenchmark.cpp index eef360e..bb0f692 100644 --- a/tests/storagebenchmark.cpp +++ b/tests/storagebenchmark.cpp @@ -1,6 +1,6 @@ #include -#include "event_generated.h" +#include "dummy_generated.h" #include "hawd/dataset.h" #include "hawd/formatter.h" @@ -16,7 +16,7 @@ using namespace Sink::ApplicationDomain::Buffer; using namespace flatbuffers; -static QByteArray createEvent() +static QByteArray createEntity() { static const size_t attachmentSize = 1024 * 2; // 2KB static uint8_t rawData[attachmentSize]; @@ -25,10 +25,11 @@ static QByteArray createEvent() { uint8_t *rawDataPtr = Q_NULLPTR; auto summary = fbb.CreateString("summary"); - EventBuilder eventBuilder(fbb); - eventBuilder.add_summary(summary); - auto eventLocation = eventBuilder.Finish(); - FinishEventBuffer(fbb, eventLocation); + auto data = fbb.CreateUninitializedVector(attachmentSize, &rawDataPtr); + DummyBuilder builder(fbb); + builder.add_summary(summary); + builder.add_attachment(data); + FinishDummyBuffer(fbb, builder.Finish()); memcpy((void *)rawDataPtr, rawData, attachmentSize); } @@ -65,7 +66,7 @@ private slots: void testWriteRead() { - auto event = createEvent(); + auto entity = createEntity(); QScopedPointer store(new Sink::Storage::DataStore(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite)); @@ -77,7 +78,7 @@ private slots: { auto transaction = store->createTransaction(Sink::Storage::DataStore::ReadWrite); for (int i = 0; i < count; i++) { - transaction.openDatabase().write(keyPrefix + QByteArray::number(i), event); + transaction.openDatabase().write(keyPrefix + QByteArray::number(i), entity); if ((i % 10000) == 0) { transaction.commit(); transaction = store->createTransaction(Sink::Storage::DataStore::ReadWrite); @@ -93,7 +94,7 @@ private slots: std::ofstream myfile; myfile.open(filePath.toStdString()); for (int i = 0; i < count; i++) { - myfile << event.toStdString(); + myfile << entity.toStdString(); } myfile.close(); } @@ -194,7 +195,8 @@ private slots: time.start(); for (int i = 0; i < count; i++) { - auto event = createEvent(); + auto entity = createEntity(); + Q_UNUSED(entity); } qreal bufferDuration = time.restart(); -- cgit v1.2.3