Count the number of requests per operator

This commit is contained in:
János Benjamin Antal 2022-11-02 14:02:19 +01:00
parent c92c795b1a
commit a96f489756
2 changed files with 9 additions and 3 deletions

View File

@ -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};

View File

@ -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<uint64_t>();
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<uint64_t>();
json_data = numerical_data + increment;
}
std::string_view custom_data_name_;
uint64_t start_time_;
ExecutionContext *context_;