Skip to content

Commit

Permalink
change: Make proc widget unit consistent with disk (#443)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ClementTsang authored Apr 4, 2021
1 parent eb6a737 commit 476aaff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

- [#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

- [#416](https://github.com/ClementTsang/bottom/pull/416): Fixes grouped vs ungrouped modes in the processes widget having inconsistent spacing.
Expand Down
16 changes: 9 additions & 7 deletions src/data_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,10 @@ pub fn convert_process_data(
existing_converted_process_data.keys().copied().collect();

for process in &current_data.process_harvest {
let converted_rps = get_binary_bytes(process.read_bytes_per_sec);
let converted_wps = get_binary_bytes(process.write_bytes_per_sec);
let converted_total_read = get_binary_bytes(process.total_read_bytes);
let converted_total_write = get_binary_bytes(process.total_write_bytes);
let converted_rps = get_decimal_bytes(process.read_bytes_per_sec);
let converted_wps = get_decimal_bytes(process.write_bytes_per_sec);
let converted_total_read = get_decimal_bytes(process.total_read_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 write_per_sec = format!("{:.*}{}/s", 0, converted_wps.0, converted_wps.1);
Expand All @@ -601,6 +601,8 @@ pub fn convert_process_data(
0, converted_total_write.0, converted_total_write.1
);

let mem_usage_str = get_decimal_bytes(process.mem_usage_bytes);

let user = {
#[cfg(target_family = "unix")]
{
Expand All @@ -626,7 +628,7 @@ pub fn convert_process_data(
process_entry.cpu_percent_usage = process.cpu_usage_percent;
process_entry.mem_percent_usage = process.mem_usage_percent;
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.read_per_sec = read_per_sec;
process_entry.write_per_sec = write_per_sec;
Expand All @@ -652,7 +654,7 @@ pub fn convert_process_data(
cpu_percent_usage: process.cpu_usage_percent,
mem_percent_usage: process.mem_usage_percent,
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],
read_per_sec,
write_per_sec,
Expand Down Expand Up @@ -682,7 +684,7 @@ pub fn convert_process_data(
cpu_percent_usage: process.cpu_usage_percent,
mem_percent_usage: process.mem_usage_percent,
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],
read_per_sec,
write_per_sec,
Expand Down

0 comments on commit 476aaff

Please sign in to comment.