From 430799c3fc8ef473e390f6a6977a7aca695796ad Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Tue, 2 Dec 2014 16:10:29 +0100 Subject: split out the buffer creation timing into a new test, tune the read/write test --- store/test/storagebenchmark.cpp | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) (limited to 'store/test/storagebenchmark.cpp') diff --git a/store/test/storagebenchmark.cpp b/store/test/storagebenchmark.cpp index 939ae0b..6fc50f6 100644 --- a/store/test/storagebenchmark.cpp +++ b/store/test/storagebenchmark.cpp @@ -32,11 +32,11 @@ static std::string createEvent() return std::string(reinterpret_cast(fbb.GetBufferPointer()), fbb.GetSize()); } -static void readEvent(const std::string &data) -{ - auto readEvent = GetEvent(data.c_str()); - std::cout << readEvent->summary()->c_str() << std::endl; -} +// static void readEvent(const std::string &data) +// { +// auto readEvent = GetEvent(data.c_str()); +// std::cout << readEvent->summary()->c_str() << std::endl; +// } class StorageBenchmark : public QObject { @@ -46,6 +46,7 @@ private: QString testDataPath; QString dbPath; QString filePath; + const int count = 50000; private Q_SLOTS: void initTestCase() @@ -65,7 +66,6 @@ private Q_SLOTS: QTest::addColumn("useDb"); QTest::addColumn("count"); - const int count = 50000; QTest::newRow("db, 50k") << true << count; QTest::newRow("file, 50k") << false << count; } @@ -79,16 +79,21 @@ private Q_SLOTS: std::ofstream myfile; myfile.open(filePath.toStdString()); + const char *keyPrefix = "key"; QTime time; + time.start(); { auto transaction = db.startTransaction(); + auto event = createEvent(); for (int i = 0; i < count; i++) { - const auto key = QString("key%1").arg(i); - auto event = createEvent(); + if (useDb && i > 0 && (i % 10000 == 0)) { + db.endTransaction(transaction); + transaction = db.startTransaction(); + } if (useDb) { - db.write(key.toStdString(), event, transaction); + db.write(keyPrefix + std::to_string(i), event, transaction); } else { myfile << event; } @@ -105,13 +110,13 @@ private Q_SLOTS: time.start(); { for (int i = 0; i < count; i++) { - const auto key = QString("key%1").arg(i); if (useDb) { - db.read(key.toStdString()); + db.read(keyPrefix + std::to_string(i)); } } } const int readDuration = time.elapsed(); + if (useDb) { qDebug() << "Reading took[ms]: " << readDuration; } else { @@ -119,6 +124,20 @@ private Q_SLOTS: } } + void testBufferCreation() + { + QTime time; + + time.start(); + { + for (int i = 0; i < count; i++) { + auto event = createEvent(); + } + } + const int bufferDuration = time.elapsed(); + qDebug() << "Creating buffers took[ms]: " << bufferDuration; + } + void testSizes() { QFileInfo dbInfo(dbPath, "data.mdb"); -- cgit v1.2.3