change: Make proc widget unit consistent with disk (#443)

In particular, use non-binary prefixes for disk and memory usage in a process. Ideally everything is configurable by the user, but this is fine for now IMO until I can get around to doing in-app config.
This commit is contained in:
Clement Tsang 2021-04-04 17:03:52 -04:00 committed by GitHub
parent eb6a737d34
commit 476aaff45c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View file

@ -43,6 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#437](https://github.com/ClementTsang/bottom/pull/437): Add linear interpolation step in drawing step to pr event missing entries on the right side of charts. - [#437](https://github.com/ClementTsang/bottom/pull/437): Add linear interpolation step in drawing step to pr event missing entries on the right side of charts.
- [#443](https://github.com/ClementTsang/bottom/pull/443): Make process widget consistent with disk widget in using decimal prefixes (kilo, mega, etc.) for memory usage and writes/reads.
## Bug Fixes ## Bug Fixes
- [#416](https://github.com/ClementTsang/bottom/pull/416): Fixes grouped vs ungrouped modes in the processes widget having inconsistent spacing. - [#416](https://github.com/ClementTsang/bottom/pull/416): Fixes grouped vs ungrouped modes in the processes widget having inconsistent spacing.

View file

@ -588,10 +588,10 @@ pub fn convert_process_data(
existing_converted_process_data.keys().copied().collect(); existing_converted_process_data.keys().copied().collect();
for process in &current_data.process_harvest { for process in &current_data.process_harvest {
let converted_rps = get_binary_bytes(process.read_bytes_per_sec); let converted_rps = get_decimal_bytes(process.read_bytes_per_sec);
let converted_wps = get_binary_bytes(process.write_bytes_per_sec); let converted_wps = get_decimal_bytes(process.write_bytes_per_sec);
let converted_total_read = get_binary_bytes(process.total_read_bytes); let converted_total_read = get_decimal_bytes(process.total_read_bytes);
let converted_total_write = get_binary_bytes(process.total_write_bytes); let converted_total_write = get_decimal_bytes(process.total_write_bytes);
let read_per_sec = format!("{:.*}{}/s", 0, converted_rps.0, converted_rps.1); let read_per_sec = format!("{:.*}{}/s", 0, converted_rps.0, converted_rps.1);
let write_per_sec = format!("{:.*}{}/s", 0, converted_wps.0, converted_wps.1); let write_per_sec = format!("{:.*}{}/s", 0, converted_wps.0, converted_wps.1);
@ -601,6 +601,8 @@ pub fn convert_process_data(
0, converted_total_write.0, converted_total_write.1 0, converted_total_write.0, converted_total_write.1
); );
let mem_usage_str = get_decimal_bytes(process.mem_usage_bytes);
let user = { let user = {
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
{ {
@ -626,7 +628,7 @@ pub fn convert_process_data(
process_entry.cpu_percent_usage = process.cpu_usage_percent; process_entry.cpu_percent_usage = process.cpu_usage_percent;
process_entry.mem_percent_usage = process.mem_usage_percent; process_entry.mem_percent_usage = process.mem_usage_percent;
process_entry.mem_usage_bytes = process.mem_usage_bytes; process_entry.mem_usage_bytes = process.mem_usage_bytes;
process_entry.mem_usage_str = get_binary_bytes(process.mem_usage_bytes); process_entry.mem_usage_str = mem_usage_str;
process_entry.group_pids = vec![process.pid]; process_entry.group_pids = vec![process.pid];
process_entry.read_per_sec = read_per_sec; process_entry.read_per_sec = read_per_sec;
process_entry.write_per_sec = write_per_sec; process_entry.write_per_sec = write_per_sec;
@ -652,7 +654,7 @@ pub fn convert_process_data(
cpu_percent_usage: process.cpu_usage_percent, cpu_percent_usage: process.cpu_usage_percent,
mem_percent_usage: process.mem_usage_percent, mem_percent_usage: process.mem_usage_percent,
mem_usage_bytes: process.mem_usage_bytes, mem_usage_bytes: process.mem_usage_bytes,
mem_usage_str: get_binary_bytes(process.mem_usage_bytes), mem_usage_str,
group_pids: vec![process.pid], group_pids: vec![process.pid],
read_per_sec, read_per_sec,
write_per_sec, write_per_sec,
@ -682,7 +684,7 @@ pub fn convert_process_data(
cpu_percent_usage: process.cpu_usage_percent, cpu_percent_usage: process.cpu_usage_percent,
mem_percent_usage: process.mem_usage_percent, mem_percent_usage: process.mem_usage_percent,
mem_usage_bytes: process.mem_usage_bytes, mem_usage_bytes: process.mem_usage_bytes,
mem_usage_str: get_binary_bytes(process.mem_usage_bytes), mem_usage_str,
group_pids: vec![process.pid], group_pids: vec![process.pid],
read_per_sec, read_per_sec,
write_per_sec, write_per_sec,