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/CMakeLists.txt | 30 --------------------- buffertest/calendar.fbs | 12 --------- buffertest/main.cpp | 67 ----------------------------------------------- 3 files changed, 109 deletions(-) delete mode 100644 buffertest/CMakeLists.txt delete mode 100644 buffertest/calendar.fbs delete mode 100644 buffertest/main.cpp (limited to 'buffertest') diff --git a/buffertest/CMakeLists.txt b/buffertest/CMakeLists.txt deleted file mode 100644 index fd100d0..0000000 --- a/buffertest/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -project(toynadi_buffertest) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -set(store_path "../store/") - -set(toynadinbuffertest_SRCS - ${store_path}/database.cpp - main.cpp -) - -set(SCHEMAS calendar.fbs) -set(SCHEMA_SOURCEFILES calendar_generated.h) - -add_custom_command(OUTPUT ${SCHEMA_SOURCEFILES} - COMMAND flatc -c ${CMAKE_CURRENT_SOURCE_DIR}/calendar.fbs - COMMENT "Generating buffers" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${SCHEMAS} - VERBATIM -) - -SET_SOURCE_FILES_PROPERTIES(${SCHEMA_SOURCEFILES} PROPERTIES GENERATED 1) -ADD_CUSTOM_TARGET(generate_buffers ALL DEPENDS ${SCHEMA_SOURCEFILES}) - -add_executable(${PROJECT_NAME} ${toynadinbuffertest_SRCS}) -qt5_use_modules(${PROJECT_NAME} Core) -target_link_libraries(${PROJECT_NAME} lmdb) -install(TARGETS ${PROJECT_NAME} DESTINATION bin) - diff --git a/buffertest/calendar.fbs b/buffertest/calendar.fbs deleted file mode 100644 index 203ee43..0000000 --- a/buffertest/calendar.fbs +++ /dev/null @@ -1,12 +0,0 @@ -// example IDL file - -namespace Calendar; - -table Event { - summary:string; - description:string; - attachment:[byte]; -} - -root_type Event; -file_identifier "AKFB"; 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