bug: fix total read/write units having /s (#763)
Fixes the total read/write columns in processes using the wrong unit (having /s).
This commit is contained in:
parent
d3a187b529
commit
121632760d
src
|
@ -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(),
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue