diff --git a/src/windows/process.rs b/src/windows/process.rs index 20d580c6f..64efabeab 100644 --- a/src/windows/process.rs +++ b/src/windows/process.rs @@ -956,6 +956,11 @@ fn check_sub(a: u64, b: u64) -> u64 { /// Before changing this function, you must consider the following: /// 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(); @@ -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(