mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-10 14:44:18 +00:00
bug: fix is_nan being incorrectly used to check for division by zero (#905)
This commit is contained in:
parent
63df220a38
commit
abff6e4a7a
2 changed files with 10 additions and 8 deletions
|
@ -50,11 +50,12 @@ where
|
|||
};
|
||||
|
||||
let pcu = {
|
||||
let p = process_val.cpu_usage() as f64 / num_processors;
|
||||
if p.is_nan() {
|
||||
process_val.cpu_usage() as f64
|
||||
let usage = process_val.cpu_usage() as f64;
|
||||
let res = usage / num_processors;
|
||||
if res.is_finite() {
|
||||
res
|
||||
} else {
|
||||
p
|
||||
usage
|
||||
}
|
||||
};
|
||||
let process_cpu_usage = if use_current_cpu_total && cpu_usage > 0.0 {
|
||||
|
|
|
@ -42,11 +42,12 @@ pub fn get_process_data(
|
|||
};
|
||||
|
||||
let pcu = {
|
||||
let p = process_val.cpu_usage() as f64 / num_processors;
|
||||
if p.is_nan() {
|
||||
process_val.cpu_usage() as f64
|
||||
let usage = process_val.cpu_usage() as f64;
|
||||
let res = usage / num_processors;
|
||||
if res.is_finite() {
|
||||
res
|
||||
} else {
|
||||
p
|
||||
usage
|
||||
}
|
||||
};
|
||||
let process_cpu_usage = if use_current_cpu_total && cpu_usage > 0.0 {
|
||||
|
|
Loading…
Reference in a new issue