Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change: Make proc widget unit consistent with disk #443

Merged
merged 2 commits into from
Apr 4, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make proc widget unit consistent with disk
In particular, use non-binary prefixes for disk and memory usage in a
process.
  • Loading branch information
ClementTsang committed Apr 4, 2021
commit f09241301ff4346874e468e73c88fd67d3966983
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