Skip to content

Commit

Permalink
early return
Browse files Browse the repository at this point in the history
  • Loading branch information
provrb committed Jan 9, 2025
1 parent 127d10a commit bb47efe
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,11 @@ fn check_sub(a: u64, b: u64) -> u64 {
/// Before changing this function, you must consider the following:
/// <https://github.com/GuillaumeGomez/sysinfo/issues/459>
pub(crate) fn compute_cpu_usage(p: &mut ProcessInner, nb_cpus: u64) {
if p.cpu_calc_values.last_update.elapsed() <= MINIMUM_CPU_UPDATE_INTERVAL {
// cpu usage hasn't updated. p.cpu_usage remains the same
return;
}

unsafe {
let mut ftime: FILETIME = zeroed();
let mut fsys: FILETIME = zeroed();
Expand All @@ -968,11 +973,6 @@ pub(crate) fn compute_cpu_usage(p: &mut ProcessInner, nb_cpus: u64) {
let _err = GetProcessTimes(handle, &mut ftime, &mut ftime, &mut fsys, &mut fuser);
}

if p.cpu_calc_values.last_update.elapsed() <= MINIMUM_CPU_UPDATE_INTERVAL {
// cpu usage hasn't updated. p.cpu_usage remains the same
return;
}

// system times have changed, we need to get most recent system times
// and update the cpu times cache, as well as global_kernel_time and global_user_time
let _err = GetSystemTimes(
Expand Down

0 comments on commit bb47efe

Please sign in to comment.