diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2021-04-09 16:14:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-09 16:14:01 -0400 |
commit | cc03d57f37e4beb28d135451b32c7ba26c548133 (patch) | |
tree | 0363595da9f5f87a45a3e97c0e4149c57c13ad8e /src/data_conversion.rs | |
parent | 8c7e85b923a7c94e9425f6670d1051de1ebe8f17 (diff) |
change: Add decimal to disk values larger than 1GB (#451)
A bit of a followup to #449, this adds decimal places for values over 1GB in regards to disk usage. This affects the disk widget (for the read/write per second) and process widgets (total read, total write, read/write per second).
Diffstat (limited to 'src/data_conversion.rs')
-rw-r--r-- | src/data_conversion.rs | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/data_conversion.rs b/src/data_conversion.rs index 185aa811..c0f8529e 100644 --- a/src/data_conversion.rs +++ b/src/data_conversion.rs @@ -586,13 +586,32 @@ fn get_disk_io_strings( let converted_total_write = get_decimal_bytes(total_write); ( - format!("{:.*}{}/s", 0, converted_rps.0, converted_rps.1), - format!("{:.*}{}/s", 0, converted_wps.0, converted_wps.1), - format!("{:.*}{}", 0, converted_total_read.0, converted_total_read.1), - format!( - "{:.*}{}", - 0, converted_total_write.0, converted_total_write.1 - ), + if rps >= GIGA_LIMIT { + format!("{:.*}{}/s", 1, converted_rps.0, converted_rps.1) + } else { + format!("{:.*}{}/s", 0, converted_rps.0, converted_rps.1) + }, + if wps >= GIGA_LIMIT { + format!("{:.*}{}/s", 1, converted_wps.0, converted_wps.1) + } else { + format!("{:.*}{}/s", 0, converted_wps.0, converted_wps.1) + }, + if total_read >= GIGA_LIMIT { + format!("{:.*}{}", 1, converted_total_read.0, converted_total_read.1) + } else { + format!("{:.*}{}", 0, converted_total_read.0, converted_total_read.1) + }, + if total_write >= GIGA_LIMIT { + format!( + "{:.*}{}", + 1, converted_total_write.0, converted_total_write.1 + ) + } else { + format!( + "{:.*}{}", + 0, converted_total_write.0, converted_total_write.1 + ) + }, ) } |