From 1058363ff52f53ce6ff0c4e995ff88d6a10b6a94 Mon Sep 17 00:00:00 2001 From: Josh Finken Date: Tue, 17 Oct 2023 15:44:51 -0600 Subject: [PATCH] Update the resource-utilization calc to an average over the last N milliseconds. Previously, RU was calculated since program-start. This commit changes this calculation to average over the last N milliseconds. --- performance_metrics/src/resource_usage_logger.cpp | 8 +++++++- performance_test_factory/src/cli_options.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/performance_metrics/src/resource_usage_logger.cpp b/performance_metrics/src/resource_usage_logger.cpp index 4fe94a9d..60766711 100644 --- a/performance_metrics/src/resource_usage_logger.cpp +++ b/performance_metrics/src/resource_usage_logger.cpp @@ -49,7 +49,9 @@ void ResourceUsageLogger::start(std::chrono::milliseconds period) std::cout << "[ResourceUsageLogger]: Logging to " << m_filename << std::endl; m_t1_real_start = std::chrono::steady_clock::now(); - m_t1_user = std::clock(); + // Question: make this a flag? That is, calc RU since program start or over + // the last `period` ms. + //m_t1_user = std::clock(); m_t1_real = std::chrono::steady_clock::now(); m_logger_thread_done = false; @@ -58,6 +60,10 @@ void ResourceUsageLogger::start(std::chrono::milliseconds period) [ = ]() { int64_t i = 1; while (m_is_logging) { + // Updating m_t1_user here will have the effect of averaging resource + // utilization only over the last `period` milliseconds, *not* since + // program start. + m_t1_user = std::clock(); std::this_thread::sleep_until(m_t1_real_start + period * i); if (i == 1) { _print_header(m_file); diff --git a/performance_test_factory/src/cli_options.cpp b/performance_test_factory/src/cli_options.cpp index 96bbd185..de141755 100644 --- a/performance_test_factory/src/cli_options.cpp +++ b/performance_test_factory/src/cli_options.cpp @@ -29,7 +29,7 @@ Options::Options() name_threads = true; duration_sec = 5; csv_out = false; - resources_sampling_per_ms = 500; + resources_sampling_per_ms = 1000; tracking_options.is_enabled = false; tracking_options.late_percentage = 20; tracking_options.late_absolute_us = 5000;