Measure times in hardcoded queries

Reviewers: buda

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D410
This commit is contained in:
Mislav Bradac 2017-05-30 19:31:00 +02:00
parent 34b6afdf92
commit 2005056cd5
16 changed files with 26 additions and 47 deletions

View File

@ -69,14 +69,36 @@ class QueryEngine : public Loggable {
return true;
}
clock_t start_time = clock();
auto preprocessed = preprocessor.preprocess(query);
clock_t end_parsing_time = clock();
auto plan = LoadCypher(preprocessed);
clock_t end_planning_time = clock();
auto result = plan->run(db_accessor, preprocessed.arguments, stream);
clock_t end_execution_time = clock();
if (UNLIKELY(!result)) {
// info because it might be something like deadlock in which
// case one thread is stopped and user has try again
logger.info("Unable to execute query (execution returned false)");
return result;
}
// helper function for calculating time in seconds
auto time_second = [](clock_t start, clock_t end) {
return query::TypedValue(double(end - start) / CLOCKS_PER_SEC);
};
std::map<std::string, query::TypedValue> summary;
summary["query_parsing_time"] = time_second(start_time, end_parsing_time);
// This doesn't do any actual planning, but benchmarking harness knows how
// to work with this field.
summary["query_planning_time"] =
time_second(end_parsing_time, end_planning_time);
summary["query_plan_execution_time"] =
time_second(end_planning_time, end_execution_time);
summary["type"] = "rw";
stream.Summary(summary);
return result;
}

View File

@ -186,8 +186,10 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args,
for (auto x : V) {
auto edge = get_edge(vertices[profile_index], *vertices_indexed[x]);
if (edge == nullptr) continue;
auto prop = query::TypedValue(edge->PropsAt(db_accessor.property("score")));
if (prop.type() == query::TypedValue::Type::Int) res += prop.Value<int64_t>();
auto prop =
query::TypedValue(edge->PropsAt(db_accessor.property("score")));
if (prop.type() == query::TypedValue::Type::Int)
res += prop.Value<int64_t>();
}
return res;
};
@ -213,8 +215,5 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args,
result.push_back(calc_score(results[i]));
stream.Result(result);
}
std::map<std::string, query::TypedValue> meta{
std::make_pair(std::string("type"), query::TypedValue(std::string("r")))};
stream.Summary(meta);
return true;
}

View File

@ -28,9 +28,6 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Header(headers);
std::vector<TypedValue> result{TypedValue(v)};
stream.Result(result);
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
return true;
}

View File

@ -26,9 +26,6 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Header(headers);
std::vector<TypedValue> result{TypedValue(v)};
stream.Result(result);
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
return true;
}

View File

@ -28,9 +28,6 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Header(headers);
std::vector<TypedValue> result{TypedValue(v)};
stream.Result(result);
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
return true;
}

View File

@ -26,9 +26,6 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Header(headers);
std::vector<TypedValue> result{TypedValue(v)};
stream.Result(result);
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
return true;
}

View File

@ -28,9 +28,6 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Header(headers);
std::vector<TypedValue> result{TypedValue(v)};
stream.Result(result);
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
return true;
}

View File

@ -28,9 +28,6 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Header(headers);
std::vector<TypedValue> result{TypedValue(v)};
stream.Result(result);
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
return true;
}

View File

@ -20,9 +20,6 @@ class CPUPlan : public PlanInterface<Stream> {
for (auto v : db_accessor.vertices()) db_accessor.detach_remove_vertex(v);
std::vector<std::string> headers;
stream.Header(headers);
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
return true;
}

View File

@ -31,9 +31,6 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Result(result);
}
}
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("r")))};
stream.Summary(meta);
return true;
}
~CPUPlan() {}

View File

@ -49,9 +49,6 @@ class CPUPlan : public PlanInterface<Stream> {
std::vector<TypedValue> result{TypedValue(e)};
stream.Result(result);
}
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
return true;
}

View File

@ -31,8 +31,5 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args,
stream.Result(result);
}
}
std::map<std::string, query::TypedValue> meta{std::make_pair(
std::string("type"), query::TypedValue(std::string("rw")))};
stream.Summary(meta);
return true;
}

View File

@ -37,9 +37,6 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Result(result);
}
}
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("r")))};
stream.Summary(meta);
return true;
}
~CPUPlan() {}

View File

@ -52,9 +52,6 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Result(result);
}
}
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("r")))};
stream.Summary(meta);
return true;
}

View File

@ -56,9 +56,6 @@ class CPUPlan : public PlanInterface<Stream> {
std::vector<TypedValue> result{TypedValue(e)};
stream.Result(result);
}
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
return true;
}

View File

@ -53,9 +53,6 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Result(result);
}
}
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
return true;
}