Skip to content

Commit

Permalink
Merge pull request #127 from jfinken/jfinken/change-avg-ru-calculation
Browse files Browse the repository at this point in the history
Update the resource-utilization calc: average over the last N ms
  • Loading branch information
mauropasse authored Oct 30, 2023
2 parents 5193725 + 84e4d27 commit f1e7eba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions performance_metrics/src/resource_usage_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,18 @@ 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();
m_t1_real = std::chrono::steady_clock::now();
m_logger_thread_done = false;

// create a detached thread that monitors resource usage periodically
m_logger_thread = std::thread(
[ = ]() {
int64_t i = 1;
while (m_is_logging) {
// Updating m_t1_user and m_t1_real here will have the effect of calculating
// resource utilization only over the last `period` milliseconds, *not*
// since program start.
m_t1_user = std::clock();
m_t1_real = std::chrono::steady_clock::now();
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 f1e7eba

Please sign in to comment.