bug: fix incorrect parsing for process i/o calc

Cause was checking the wrong indices for values.  I thought I
had taken in a vector of strings that were just byte values,
but they actually contained the labels... oops.
This commit is contained in:
ClementTsang 2020-05-21 14:02:49 -04:00
parent f3ca98fe30
commit dcaef7ebc4
2 changed files with 10 additions and 4 deletions

View File

@ -25,6 +25,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Make highlighted CPU persist even if widget is not selected - this should help make it easier to know what CPU you are looking at
even if you aren't currently on the CPU widget.
### Bug Fixes
- Fixed a bug where bottom would incorrectly read the wrong values to calculate the read/write columns for processes in Linux.
## [0.4.3] - 2020-05-15
### Other

View File

@ -138,8 +138,8 @@ fn get_process_io(path: &PathBuf) -> std::io::Result<String> {
fn get_linux_process_io_usage(io_stats: &[&str]) -> (u64, u64) {
// Represents read_bytes and write_bytes
(
io_stats[4].parse::<u64>().unwrap_or(0),
io_stats[5].parse::<u64>().unwrap_or(0),
io_stats[9].parse::<u64>().unwrap_or(0),
io_stats[11].parse::<u64>().unwrap_or(0),
)
}
@ -240,12 +240,14 @@ fn convert_ps<S: core::hash::BuildHasher>(
let read_bytes_per_sec = if time_difference_in_secs == 0 {
0
} else {
(total_write_bytes - new_pid_stat.total_write_bytes) / time_difference_in_secs
total_read_bytes.saturating_sub(new_pid_stat.total_read_bytes)
/ time_difference_in_secs
};
let write_bytes_per_sec = if time_difference_in_secs == 0 {
0
} else {
(total_read_bytes - new_pid_stat.total_read_bytes) / time_difference_in_secs
total_write_bytes.saturating_sub(new_pid_stat.total_write_bytes)
/ time_difference_in_secs
};
new_pid_stat.total_read_bytes = total_read_bytes;