6cd63e8ac9
Summary: It's purpose is to illustrate that currently expansion from a single node (with a fixed degree) does not execute in consistent time, but the execution time depends on the rest of the graph (that's disconnected). Current benchmark results: ``` florijan@florxps:~/Memgraph/memgraph/build$ ./tests/benchmark/expansion Run on (8 X 3500 MHz CPU s) 2017-08-17 16:06:30 ***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead. ***WARNING*** Library was built as DEBUG. Timings may be affected. Benchmark Time CPU Iterations ------------------------------------------------------------------------- ExpansionBenchFixture/Match/1 0 ms 0 ms 4903 ExpansionBenchFixture/Match/1024 0 ms 0 ms 4785 ExpansionBenchFixture/Match/1024k 0 ms 0 ms 4623 ExpansionBenchFixture/Expand/1 9 ms 9 ms 83 ExpansionBenchFixture/Expand/1024 20 ms 20 ms 41 ExpansionBenchFixture/Expand/1024k 3430 ms 3430 ms 1 ``` Reviewers: mislav.bradac, buda Reviewed By: mislav.bradac Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D676
75 lines
2.1 KiB
C++
75 lines
2.1 KiB
C++
#include <benchmark/benchmark.h>
|
|
#include <benchmark/benchmark_api.h>
|
|
#include <glog/logging.h>
|
|
|
|
#include "communication/result_stream_faker.hpp"
|
|
#include "database/dbms.hpp"
|
|
#include "query/interpreter.hpp"
|
|
#include "query/typed_value.hpp"
|
|
|
|
class ExpansionBenchFixture : public benchmark::Fixture {
|
|
protected:
|
|
std::experimental::optional<Dbms> dbms_;
|
|
query::Interpreter interpeter_;
|
|
|
|
void SetUp(const benchmark::State &state) override {
|
|
if (!dbms_)
|
|
dbms_.emplace();
|
|
auto dba = dbms_->active();
|
|
for (int i = 0; i < state.range(0); i++) dba->InsertVertex();
|
|
|
|
// the fixed part is one vertex expanding to 1000 others
|
|
auto start = dba->InsertVertex();
|
|
start.add_label(dba->Label("Start"));
|
|
auto edge_type = dba->EdgeType("edge_type");
|
|
for (int i = 0; i < 1000; i++) {
|
|
auto dest = dba->InsertVertex();
|
|
dba->InsertEdge(start, dest, edge_type);
|
|
}
|
|
dba->Commit();
|
|
}
|
|
|
|
void TearDown(const benchmark::State &) override {
|
|
auto dba = dbms_->active();
|
|
for (auto vertex : dba->Vertices(false)) dba->DetachRemoveVertex(vertex);
|
|
dba->Commit();
|
|
}
|
|
};
|
|
|
|
BENCHMARK_DEFINE_F(ExpansionBenchFixture, Match)(benchmark::State &state) {
|
|
auto query = "MATCH (s:Start) return s";
|
|
auto dba = dbms_->active();
|
|
while (state.KeepRunning()) {
|
|
ResultStreamFaker results;
|
|
interpeter_.Interpret(query, *dba, results, {});
|
|
}
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(ExpansionBenchFixture, Match)
|
|
->RangeMultiplier(1024)
|
|
->Range(1, 1 << 20)
|
|
->Unit(benchmark::kMillisecond);
|
|
|
|
BENCHMARK_DEFINE_F(ExpansionBenchFixture, Expand)(benchmark::State &state) {
|
|
auto query = "MATCH (s:Start) WITH s MATCH (s)--(d) RETURN count(d)";
|
|
auto dba = dbms_->active();
|
|
while (state.KeepRunning()) {
|
|
ResultStreamFaker results;
|
|
interpeter_.Interpret(query, *dba, results, {});
|
|
}
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(ExpansionBenchFixture, Expand)
|
|
->RangeMultiplier(1024)
|
|
->Range(1, 1 << 20)
|
|
->Unit(benchmark::kMillisecond);
|
|
|
|
int main(int argc, char **argv) {
|
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
|
google::InitGoogleLogging(argv[0]);
|
|
|
|
::benchmark::Initialize(&argc, argv);
|
|
::benchmark::RunSpecifiedBenchmarks();
|
|
return 0;
|
|
}
|