Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the resource-utilization calc: average over the last N ms #127

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a situation in which we need to use the previous behavior, we could add a flag.
I don't foresee an use case for this though, and wrt some kind of "backward compatibility", we always looked into the last values of the CPU, right before the program finishes (which now we could get more quickly, after maybe just 5 seconds instead of 60).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I'll remove the question/comment. Thanks.

// 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
Loading