From da0e1bb93de6d45c261a0e48f024f1b0ce92b2d2 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 12 Oct 2017 16:10:17 +0200 Subject: Changed how we record and print the mail query benchmark data. Each column can represent an individual value, which we can use to record related data. Each row thus represents a new run of the benchmark. --- tests/hawd/modules/json.cpp | 8 ++++- tests/mailquerybenchmark.cpp | 78 +++++++++++++++++++++++--------------------- 2 files changed, 48 insertions(+), 38 deletions(-) (limited to 'tests') diff --git a/tests/hawd/modules/json.cpp b/tests/hawd/modules/json.cpp index d08df49..d299761 100644 --- a/tests/hawd/modules/json.cpp +++ b/tests/hawd/modules/json.cpp @@ -73,9 +73,15 @@ bool Json::toJson(const QStringList &commands, State &state) QJsonObject jsonRow; jsonRow.insert("timestamp", QJsonValue::fromVariant(row.timestamp())); jsonRow.insert("commit", row.commitHash()); + QJsonArray columnsArray; for (const auto &col : columns) { - jsonRow.insert(col.first, QJsonValue::fromVariant(row.value(col.first))); + QJsonObject columnObject; + columnObject.insert("unit", QJsonValue::fromVariant(col.second.unit())); + columnObject.insert("name", QJsonValue::fromVariant(col.first)); + columnObject.insert("value", QJsonValue::fromVariant(row.value(col.first))); + columnsArray << columnObject; } + jsonRow.insert("columns", columnsArray); array.append(jsonRow); }); json.insert("rows", array); diff --git a/tests/mailquerybenchmark.cpp b/tests/mailquerybenchmark.cpp index f9a3712..f6d7130 100644 --- a/tests/mailquerybenchmark.cpp +++ b/tests/mailquerybenchmark.cpp @@ -80,7 +80,7 @@ class MailQueryBenchmark : public QObject entityStore.commitTransaction(); } - void testLoad(const QByteArray &name, const Sink::Query &query, int count, int expectedSize) + qreal testLoad(const Sink::Query &query, int count, int expectedSize) { const auto startingRss = getCurrentRSS(); @@ -105,7 +105,7 @@ class MailQueryBenchmark : public QObject while (!done) { QTest::qWait(1); } - QCOMPARE(list.size(), expectedSize); + Q_ASSERT(list.size() == expectedSize); const auto elapsed = time.elapsed(); @@ -127,21 +127,15 @@ class MailQueryBenchmark : public QObject std::cout << "Rss without db [kb]: " << rssWithoutDb / 1024 << std::endl; std::cout << "Percentage error: " << percentageRssError << std::endl; - HAWD::Dataset dataset(name, mHawdState); - HAWD::Dataset::Row row = dataset.row(); - row.setValue("rows", list.size()); - row.setValue("queryResultPerMs", (qreal)list.size() / elapsed); - dataset.insertRow(row); - HAWD::Formatter::print(dataset); - - QVERIFY(percentageRssError < 10); + Q_ASSERT(percentageRssError < 10); // TODO This is much more than it should it seems, although adding the attachment results in pretty exactly a 1k increase, // so it doesn't look like that memory is being duplicated. - QVERIFY(rssGrowthPerEntity < 3300); + Q_ASSERT(rssGrowthPerEntity < 3300); // Print memory layout, RSS is what is in memory // std::system("exec pmap -x \"$PPID\""); // std::system("top -p \"$PPID\" -b -n 1"); + return (qreal)list.size() / elapsed; } private slots: @@ -153,33 +147,43 @@ private slots: void test50k() { - Sink::Query query; - query.request() - .request() - .request(); - query.sort(); - query.filter("folder1"); - query.limit(1000); - - populateDatabase(50000); - testLoad("mail_query", query, 50000, query.limit()); - } - - void test50kThreadleader() - { - Sink::Query query; - query.request() - .request() - .request(); - // query.filter(false); - query.reduce(Query::Reduce::Selector::max()); - query.limit(1000); - - int mailsPerFolder = 10; - int count = 50000; - populateDatabase(count, mailsPerFolder); - testLoad("mail_query_threadleader", query, count, query.limit()); + int limit = 1000; + qreal simpleResultRate = 0; + qreal threadResultRate = 0; + { + Sink::Query query; + query.request() + .request() + .request(); + query.sort(); + query.filter("folder1"); + query.limit(limit); + + populateDatabase(count); + simpleResultRate = testLoad(query, count, query.limit()); + } + { + Sink::Query query; + query.request() + .request() + .request(); + // query.filter(false); + query.reduce(Query::Reduce::Selector::max()); + query.limit(limit); + + int mailsPerFolder = 10; + + populateDatabase(count, mailsPerFolder); + threadResultRate = testLoad(query, count, query.limit()); + } + HAWD::Dataset dataset("mail_query", mHawdState); + HAWD::Dataset::Row row = dataset.row(); + row.setValue("rows", limit); + row.setValue("simple", simpleResultRate); + row.setValue("threadleader", threadResultRate); + dataset.insertRow(row); + HAWD::Formatter::print(dataset); } void testIncremental() -- cgit v1.2.3