2017-02-18 21:36:50 +08:00
|
|
|
#define LOG_NO_INFO 1
|
|
|
|
|
2017-02-19 01:03:48 +08:00
|
|
|
#include "benchmark/benchmark_api.h"
|
2016-11-23 00:42:24 +08:00
|
|
|
#include "logging/default.hpp"
|
|
|
|
#include "logging/streams/stdout.hpp"
|
2017-06-08 00:28:31 +08:00
|
|
|
#include "query/stripped.hpp"
|
2016-11-23 00:42:24 +08:00
|
|
|
#include "yaml-cpp/yaml.h"
|
|
|
|
|
2016-12-22 22:51:16 +08:00
|
|
|
auto BM_Strip = [](benchmark::State &state, auto &function, std::string query) {
|
2017-02-18 18:54:37 +08:00
|
|
|
while (state.KeepRunning()) {
|
|
|
|
for (int start = 0; start < state.range(0); start++) {
|
|
|
|
function(query);
|
2016-11-23 00:42:24 +08:00
|
|
|
}
|
2017-02-18 18:54:37 +08:00
|
|
|
}
|
|
|
|
state.SetComplexityN(state.range(0));
|
2016-11-23 00:42:24 +08:00
|
|
|
};
|
|
|
|
|
2017-02-18 18:54:37 +08:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
logging::init_async();
|
|
|
|
logging::log->pipe(std::make_unique<Stdout>());
|
|
|
|
|
|
|
|
YAML::Node dataset = YAML::LoadFile(
|
|
|
|
"../../tests/data/cypher_queries/stripper/query_dict.yaml");
|
|
|
|
|
2017-06-08 00:28:31 +08:00
|
|
|
auto preprocess = [](const std::string &query) {
|
|
|
|
return query::StrippedQuery(query);
|
|
|
|
};
|
2017-02-18 18:54:37 +08:00
|
|
|
|
|
|
|
auto tests = dataset["benchmark_queries"].as<std::vector<std::string>>();
|
|
|
|
for (auto &test : tests) {
|
2017-03-21 20:48:35 +08:00
|
|
|
benchmark::RegisterBenchmark(test.c_str(), BM_Strip, preprocess, test)
|
|
|
|
->Range(1, 1)
|
|
|
|
->Complexity(benchmark::oN);
|
2017-02-18 18:54:37 +08:00
|
|
|
}
|
2016-11-23 00:42:24 +08:00
|
|
|
|
2017-02-18 18:54:37 +08:00
|
|
|
benchmark::Initialize(&argc, argv);
|
|
|
|
benchmark::RunSpecifiedBenchmarks();
|
2016-11-23 00:42:24 +08:00
|
|
|
|
2017-02-18 18:54:37 +08:00
|
|
|
return 0;
|
2016-11-23 00:42:24 +08:00
|
|
|
}
|