From a96f4897566afde491e9f3b7d7d99af0fb921205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1nos=20Benjamin=20Antal?= Date: Wed, 2 Nov 2022 14:02:19 +0100 Subject: [PATCH] Count the number of requests per operator --- src/query/v2/plan/profile.hpp | 1 + src/query/v2/plan/scoped_profile.hpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/query/v2/plan/profile.hpp b/src/query/v2/plan/profile.hpp index da25be33c..bf7687018 100644 --- a/src/query/v2/plan/profile.hpp +++ b/src/query/v2/plan/profile.hpp @@ -29,6 +29,7 @@ struct ProfilingStats { static constexpr std::string_view kNumCycles{"num_cycles"}; static constexpr std::string_view kRelativeTime{"relative_time"}; static constexpr std::string_view kAbsoluteTime{"absolute_time"}; + static constexpr std::string_view kActualHits{"actual_hits"}; int64_t actual_hits{0}; uint64_t num_cycles{0}; diff --git a/src/query/v2/plan/scoped_profile.hpp b/src/query/v2/plan/scoped_profile.hpp index 3aa4bc569..a9d4c1296 100644 --- a/src/query/v2/plan/scoped_profile.hpp +++ b/src/query/v2/plan/scoped_profile.hpp @@ -42,13 +42,18 @@ class ScopedCustomProfile { custom_data = nlohmann::json::object(); } const auto elapsed = utils::ReadTSC() - start_time_; - auto &num_cycles_json = custom_data[ProfilingStats::kNumCycles]; - const auto num_cycles = num_cycles_json.is_null() ? 0 : num_cycles_json.get(); - num_cycles_json = num_cycles + elapsed; + IncreaseCustomData(custom_data, ProfilingStats::kNumCycles, elapsed); + IncreaseCustomData(custom_data, ProfilingStats::kActualHits, 1); } } private: + static void IncreaseCustomData(nlohmann::json &custom_data, const std::string_view key, uint64_t increment) { + auto &json_data = custom_data[key]; + const auto numerical_data = json_data.is_null() ? 0 : json_data.get(); + json_data = numerical_data + increment; + } + std::string_view custom_data_name_; uint64_t start_time_; ExecutionContext *context_;