summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClementTsang <cjhtsang@uwaterloo.ca>2020-05-21 14:02:49 -0400
committerClementTsang <cjhtsang@uwaterloo.ca>2020-05-21 14:03:00 -0400
commitdcaef7ebc40dcd703d9392bc6a07fe01c789b899 (patch)
tree8b3add0ea9d1c6cdc658d82f3fe2195d333f437d
parentf3ca98fe3061793eb022c404b3997e3863534af3 (diff)
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.
-rw-r--r--CHANGELOG.md4
-rw-r--r--src/app/data_harvester/processes.rs10
2 files changed, 10 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8de06531..bff01ec7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/src/app/data_harvester/processes.rs b/src/app/data_harvester/processes.rs
index 19a05f5d..bfb820ac 100644
--- a/src/app/data_harvester/processes.rs
+++ b/src/app/data_harvester/processes.rs
@@ -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;