From 7cbf25f2f6d38efa384c7f8e0a5b2b2d274ebb00 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 30 Nov 2014 17:57:31 +0100 Subject: Moved buffertest to store/test and turned it into a reproducible benchmark. --- buffertest/main.cpp | 67 ----------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 buffertest/main.cpp (limited to 'buffertest/main.cpp') diff --git a/buffertest/main.cpp b/buffertest/main.cpp deleted file mode 100644 index 437e5b3..0000000 --- a/buffertest/main.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "calendar_generated.h" -#include -#include -#include -#include -#include -#include - -#include "store/database.h" - -using namespace Calendar; -using namespace flatbuffers; - -std::string createEvent(bool createAttachment = false) -{ - FlatBufferBuilder fbb; - { - auto summary = fbb.CreateString("summary"); - - // const int attachmentSize = 1024 * 1024; // 1MB - const int attachmentSize = 1024*2; // 1KB - int8_t rawData[attachmentSize]; - auto data = fbb.CreateVector(rawData, attachmentSize); - - Calendar::EventBuilder eventBuilder(fbb); - eventBuilder.add_summary(summary); - eventBuilder.add_attachment(data); - auto eventLocation = eventBuilder.Finish(); - FinishEventBuffer(fbb, eventLocation); - } - return std::string(reinterpret_cast(fbb.GetBufferPointer()), fbb.GetSize()); -} - -void readEvent(const std::string &data) -{ - auto readEvent = GetEvent(data.c_str()); - std::cout << readEvent->summary()->c_str() << std::endl; -} - -int main(int argc, char **argv) -{ - Database db; - const int count = 50000; - QTime time; - time.start(); - // std::ofstream myfile; - // myfile.open ("buffer.fb"); - // - auto transaction = db.startTransaction(); - for (int i = 0; i < count; i++) { - const auto key = QString("key%1").arg(i); - auto event = createEvent(true); - db.write(key.toStdString(), event, transaction); - - // myfile << createEvent(); - } - db.endTransaction(transaction); - // myfile.close(); - qDebug() << "Writing took: " << time.elapsed(); - - time.start(); - for (int i = 0; i < count; i++) { - const auto key = QString("key%1").arg(i); - db.read(key.toStdString()); - } - qDebug() << "Reading took: " << time.elapsed(); -} -- cgit v1.2.3