mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-23 13:45:12 +02:00
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
@ -9,7 +9,9 @@ use crate::{
|
|||||||
CellContent, SortOrder, SortableState, TableComponentColumn, TableComponentHeader,
|
CellContent, SortOrder, SortableState, TableComponentColumn, TableComponentHeader,
|
||||||
TableComponentState, WidthBounds,
|
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,
|
utils::gen_util::sort_partial_fn,
|
||||||
Pid,
|
Pid,
|
||||||
};
|
};
|
||||||
@ -788,10 +790,10 @@ impl ProcWidget {
|
|||||||
dec_bytes_per_second_string(process.write_bytes_per_sec).into()
|
dec_bytes_per_second_string(process.write_bytes_per_sec).into()
|
||||||
}
|
}
|
||||||
ProcWidgetColumn::TotalRead => {
|
ProcWidgetColumn::TotalRead => {
|
||||||
dec_bytes_per_second_string(process.total_read_bytes).into()
|
dec_bytes_per_string(process.total_read_bytes).into()
|
||||||
}
|
}
|
||||||
ProcWidgetColumn::TotalWrite => {
|
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 {
|
ProcWidgetColumn::State => CellContent::HasAlt {
|
||||||
main: process.process_state.0.clone().into(),
|
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.
|
/// 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.
|
/// 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 {
|
pub fn dec_bytes_per_second_string(value: u64) -> String {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user