bug: fix total read/write units having /s ()

Fixes the total read/write columns in processes using the wrong unit (having /s).
This commit is contained in:
Clement Tsang 2022-07-07 05:45:30 -04:00 committed by GitHub
parent d3a187b529
commit 121632760d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -9,7 +9,9 @@ use crate::{
CellContent, SortOrder, SortableState, TableComponentColumn, TableComponentHeader,
TableComponentState, WidthBounds,
},
data_conversion::{binary_byte_string, dec_bytes_per_second_string, TableData, TableRow},
data_conversion::{
binary_byte_string, dec_bytes_per_second_string, dec_bytes_per_string, TableData, TableRow,
},
utils::gen_util::sort_partial_fn,
Pid,
};
@ -788,10 +790,10 @@ impl ProcWidget {
dec_bytes_per_second_string(process.write_bytes_per_sec).into()
}
ProcWidgetColumn::TotalRead => {
dec_bytes_per_second_string(process.total_read_bytes).into()
dec_bytes_per_string(process.total_read_bytes).into()
}
ProcWidgetColumn::TotalWrite => {
dec_bytes_per_second_string(process.total_write_bytes).into()
dec_bytes_per_string(process.total_write_bytes).into()
}
ProcWidgetColumn::State => CellContent::HasAlt {
main: process.process_state.0.clone().into(),

View File

@ -583,6 +583,17 @@ pub fn binary_byte_string(value: u64) -> String {
}
}
/// Returns a string given a value that is converted to the closest SI-variant.
/// If the value is greater than a giga-X, then it will return a decimal place.
pub fn dec_bytes_per_string(value: u64) -> String {
let converted_values = get_decimal_bytes(value);
if value >= GIGA_LIMIT {
format!("{:.*}{}", 1, converted_values.0, converted_values.1)
} else {
format!("{:.*}{}", 0, converted_values.0, converted_values.1)
}
}
/// Returns a string given a value that is converted to the closest SI-variant, per second.
/// If the value is greater than a giga-X, then it will return a decimal place.
pub fn dec_bytes_per_second_string(value: u64) -> String {