From 7c3efb740334625f49fd80206eb8a95820a0375f Mon Sep 17 00:00:00 2001 From: FlightlessMango Date: Thu, 6 Jan 2022 12:21:42 +0100 Subject: [PATCH] Move calc benchmark into logger --- src/logging.cpp | 39 ++++++++++++++++++++++++++++++++++++++- src/logging.h | 1 + src/overlay.cpp | 38 -------------------------------------- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/logging.cpp b/src/logging.cpp index 48470a4e..7a3442b7 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -167,7 +167,7 @@ void Logger::stop_logging() { m_logging_on = false; m_log_end = Clock::now(); - calculate_benchmark_data(m_params); + calculate_benchmark_data(); if(!m_params->output_folder.empty()) { std::string program = get_wine_exe_name(); @@ -228,3 +228,40 @@ void autostart_log(int sleep) { os_time_sleep(sleep * 1000000); logger->start_logging(); } + +void Logger::calculate_benchmark_data(){ + vector sorted = benchmark.fps_data; + std::sort(sorted.begin(), sorted.end()); + benchmark.percentile_data.clear(); + + benchmark.total = 0.f; + for (auto fps_ : sorted){ + benchmark.total = benchmark.total + fps_; + } + + size_t max_label_size = 0; + + for (std::string percentile : m_params->benchmark_percentiles) { + float result; + + // special case handling for a mean-based average + if (percentile == "AVG") { + result = benchmark.total / sorted.size(); + } else { + // the percentiles are already validated when they're parsed from the config. + float fraction = parse_float(percentile) / 100; + + result = sorted[(fraction * sorted.size()) - 1]; + percentile += "%"; + } + + if (percentile.length() > max_label_size) + max_label_size = percentile.length(); + + benchmark.percentile_data.push_back({percentile, result}); + } + + for (auto& entry : benchmark.percentile_data) { + entry.first.append(max_label_size - entry.first.length(), ' '); + } +} diff --git a/src/logging.h b/src/logging.h index 9da70163..df598ffd 100644 --- a/src/logging.h +++ b/src/logging.h @@ -52,6 +52,7 @@ public: void upload_last_log(); void upload_last_logs(); + void calculate_benchmark_data(); private: std::vector m_log_array; std::vector m_log_files; diff --git a/src/overlay.cpp b/src/overlay.cpp index 81eaf9aa..532e1150 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -208,44 +208,6 @@ void update_hud_info(struct swapchain_stats& sw_stats, struct overlay_params& pa update_hud_info_with_frametime(sw_stats, params, vendorID, frametime_ns); } -void calculate_benchmark_data(overlay_params* params){ - vector sorted = benchmark.fps_data; - std::sort(sorted.begin(), sorted.end()); - benchmark.percentile_data.clear(); - - benchmark.total = 0.f; - for (auto fps_ : sorted){ - benchmark.total = benchmark.total + fps_; - } - - size_t max_label_size = 0; - - for (std::string percentile : params->benchmark_percentiles) { - float result; - - // special case handling for a mean-based average - if (percentile == "AVG") { - result = benchmark.total / sorted.size(); - } else { - // the percentiles are already validated when they're parsed from the config. - float fraction = parse_float(percentile) / 100; - - result = sorted[(fraction * sorted.size()) - 1]; - percentile += "%"; - } - - if (percentile.length() > max_label_size) - max_label_size = percentile.length(); - - benchmark.percentile_data.push_back({percentile, result}); - } - - for (auto& entry : benchmark.percentile_data) { - entry.first.append(max_label_size - entry.first.length(), ' '); - } -} - - float get_time_stat(void *_data, int _idx) { struct swapchain_stats *data = (struct swapchain_stats *) _data;