From 04670f7328cdbec27ea7afc4b2e9b83957a965b0 Mon Sep 17 00:00:00 2001 From: florijan Date: Tue, 23 May 2017 11:28:41 +0200 Subject: [PATCH] Query - separate timing for planning and execution Reviewers: mislav.bradac, buda Reviewed By: buda Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D393 --- src/query/interpreter.hpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/query/interpreter.hpp b/src/query/interpreter.hpp index d9d4690d9..9f5885784 100644 --- a/src/query/interpreter.hpp +++ b/src/query/interpreter.hpp @@ -41,6 +41,8 @@ void Interpret(const std::string &query, GraphDbAccessor &db_accessor, // generate frame based on symbol table max_position Frame frame(symbol_table.max_position()); + clock_t planning_end_time = clock(); + std::vector header; std::vector output_symbols(logical_plan->OutputSymbols(symbol_table)); if (!output_symbols.empty()) { @@ -75,9 +77,17 @@ void Interpret(const std::string &query, GraphDbAccessor &db_accessor, throw QueryRuntimeException("Unknown top level LogicalOp"); } - clock_t end_time = clock(); - double time_second = double(end_time - start_time) / CLOCKS_PER_SEC; - summary["query_time_sec"] = TypedValue(time_second); + clock_t execution_end_time = clock(); + + // helper function for calculating time in seconds + auto time_second = [](clock_t start, clock_t end) { + return TypedValue(double(end - start) / CLOCKS_PER_SEC); + }; + + summary["query_planning_time"] = time_second(start_time, planning_end_time); + summary["query_plan_execution_time"] = + time_second(planning_end_time, execution_end_time); + // // TODO set summary['type'] based on transaction metadata // the type can't be determined based only on top level LogicalOp // (for example MATCH DELETE RETURN will have Produce as it's top)