diff options
-rw-r--r-- | common/domain/dummy.fbs | 4 | ||||
-rw-r--r-- | 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 @@ | |||
1 | namespace Sink.ApplicationDomain.Buffer; | 1 | namespace Sink.ApplicationDomain.Buffer; |
2 | 2 | ||
3 | table Dummy { | 3 | table Dummy { |
4 | uid:string; | ||
5 | summary:string; | ||
6 | description:string; | ||
7 | attachment:[ubyte]; | ||
4 | } | 8 | } |
5 | 9 | ||
6 | root_type Dummy; | 10 | 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 @@ | |||
1 | #include <QtTest> | 1 | #include <QtTest> |
2 | 2 | ||
3 | #include "event_generated.h" | 3 | #include "dummy_generated.h" |
4 | 4 | ||
5 | #include "hawd/dataset.h" | 5 | #include "hawd/dataset.h" |
6 | #include "hawd/formatter.h" | 6 | #include "hawd/formatter.h" |
@@ -16,7 +16,7 @@ | |||
16 | using namespace Sink::ApplicationDomain::Buffer; | 16 | using namespace Sink::ApplicationDomain::Buffer; |
17 | using namespace flatbuffers; | 17 | using namespace flatbuffers; |
18 | 18 | ||
19 | static QByteArray createEvent() | 19 | static QByteArray createEntity() |
20 | { | 20 | { |
21 | static const size_t attachmentSize = 1024 * 2; // 2KB | 21 | static const size_t attachmentSize = 1024 * 2; // 2KB |
22 | static uint8_t rawData[attachmentSize]; | 22 | static uint8_t rawData[attachmentSize]; |
@@ -25,10 +25,11 @@ static QByteArray createEvent() | |||
25 | { | 25 | { |
26 | uint8_t *rawDataPtr = Q_NULLPTR; | 26 | uint8_t *rawDataPtr = Q_NULLPTR; |
27 | auto summary = fbb.CreateString("summary"); | 27 | auto summary = fbb.CreateString("summary"); |
28 | EventBuilder eventBuilder(fbb); | 28 | auto data = fbb.CreateUninitializedVector<uint8_t>(attachmentSize, &rawDataPtr); |
29 | eventBuilder.add_summary(summary); | 29 | DummyBuilder builder(fbb); |
30 | auto eventLocation = eventBuilder.Finish(); | 30 | builder.add_summary(summary); |
31 | FinishEventBuffer(fbb, eventLocation); | 31 | builder.add_attachment(data); |
32 | FinishDummyBuffer(fbb, builder.Finish()); | ||
32 | memcpy((void *)rawDataPtr, rawData, attachmentSize); | 33 | memcpy((void *)rawDataPtr, rawData, attachmentSize); |
33 | } | 34 | } |
34 | 35 | ||
@@ -65,7 +66,7 @@ private slots: | |||
65 | 66 | ||
66 | void testWriteRead() | 67 | void testWriteRead() |
67 | { | 68 | { |
68 | auto event = createEvent(); | 69 | auto entity = createEntity(); |
69 | 70 | ||
70 | QScopedPointer<Sink::Storage::DataStore> store(new Sink::Storage::DataStore(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite)); | 71 | QScopedPointer<Sink::Storage::DataStore> store(new Sink::Storage::DataStore(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite)); |
71 | 72 | ||
@@ -77,7 +78,7 @@ private slots: | |||
77 | { | 78 | { |
78 | auto transaction = store->createTransaction(Sink::Storage::DataStore::ReadWrite); | 79 | auto transaction = store->createTransaction(Sink::Storage::DataStore::ReadWrite); |
79 | for (int i = 0; i < count; i++) { | 80 | for (int i = 0; i < count; i++) { |
80 | transaction.openDatabase().write(keyPrefix + QByteArray::number(i), event); | 81 | transaction.openDatabase().write(keyPrefix + QByteArray::number(i), entity); |
81 | if ((i % 10000) == 0) { | 82 | if ((i % 10000) == 0) { |
82 | transaction.commit(); | 83 | transaction.commit(); |
83 | transaction = store->createTransaction(Sink::Storage::DataStore::ReadWrite); | 84 | transaction = store->createTransaction(Sink::Storage::DataStore::ReadWrite); |
@@ -93,7 +94,7 @@ private slots: | |||
93 | std::ofstream myfile; | 94 | std::ofstream myfile; |
94 | myfile.open(filePath.toStdString()); | 95 | myfile.open(filePath.toStdString()); |
95 | for (int i = 0; i < count; i++) { | 96 | for (int i = 0; i < count; i++) { |
96 | myfile << event.toStdString(); | 97 | myfile << entity.toStdString(); |
97 | } | 98 | } |
98 | myfile.close(); | 99 | myfile.close(); |
99 | } | 100 | } |
@@ -194,7 +195,8 @@ private slots: | |||
194 | time.start(); | 195 | time.start(); |
195 | 196 | ||
196 | for (int i = 0; i < count; i++) { | 197 | for (int i = 0; i < count; i++) { |
197 | auto event = createEvent(); | 198 | auto entity = createEntity(); |
199 | Q_UNUSED(entity); | ||
198 | } | 200 | } |
199 | 201 | ||
200 | qreal bufferDuration = time.restart(); | 202 | qreal bufferDuration = time.restart(); |