Skip to content

Commit

Permalink
Update the resource-utilization calc to an average over the last N mi…
Browse files Browse the repository at this point in the history
…lliseconds.

Previously, RU was calculated since program-start.  This commit changes
this calculation to average over the last N milliseconds.
  • Loading branch information
jfinken committed Oct 17, 2023
1 parent 5193725 commit 1058363
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion performance_metrics/src/resource_usage_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion performance_test_factory/src/cli_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1058363

Please sign in to comment.