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

Improve CPU usage efficiency #1448

Merged
merged 4 commits into from
Jan 10, 2025
Merged
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
Prev Previous commit
Next Next commit
Fix overlook, last update should only be set when actually retrieving…
… the new values.
  • Loading branch information
provrb committed Jan 4, 2025
commit d31b8e8a79f4555283e601d33d1e931c727fbcba
2 changes: 1 addition & 1 deletion src/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ pub(crate) fn compute_cpu_usage(p: &mut ProcessInner, nb_cpus: u64) {
user = filetime_to_u64(fuser);
global_kernel_time = filetime_to_u64(fglobal_kernel_time);
global_user_time = filetime_to_u64(fglobal_user_time);
p.cpu_calc_values.last_update = Instant::now();
}

let delta_global_kernel_time =
Expand All @@ -1005,7 +1006,6 @@ pub(crate) fn compute_cpu_usage(p: &mut ProcessInner, nb_cpus: u64) {
p.cpu_calc_values.old_process_sys_cpu = sys;
p.cpu_calc_values.old_system_user_cpu = global_user_time;
p.cpu_calc_values.old_system_sys_cpu = global_kernel_time;
p.cpu_calc_values.last_update = Instant::now();

let denominator = delta_global_user_time.saturating_add(delta_global_kernel_time) as f32;

Expand Down
Loading