diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2021-04-09 15:43:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-09 15:43:34 -0400 |
commit | edb29a43b92a1866c809267ffd774ddc1a000015 (patch) | |
tree | 2f42af4722b473c56ef1109d9c5d5a5a928a4296 | |
parent | e824eafdb242346ababb25392301f4dcaf4a3118 (diff) |
change: Add decimal to actual memory usage in proc (#449)
This change adds a decimal + single digit to memory usage values over the 1 GiB threshold. Otherwise, there is no visible change.
(Note to self: implement the per-column width system soon, this change causes some values to potentially look a bit weird in mem-non-percent mode as it is if the value is really large, like 530.2GiB pushing right up against the column width, but it's currently tied to mem-percent mode. Ugh.)
Also revert a change made by accident where I switched to a decimal prefix system (GB) for memory values. This has been reverted back to a binary prefix (GiB).
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | src/data_conversion.rs | 8 | ||||
-rw-r--r-- | src/lib.rs | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 59006b02..76d05cb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#443](https://github.com/ClementTsang/bottom/pull/443): Make process widget consistent with disk widget in using decimal prefixes (kilo, mega, etc.) for memory usage and writes/reads. +- [#449](https://github.com/ClementTsang/bottom/pull/449): Add decimal place to actual memory usage in process widget for values greater or equal to 1GiB. + ## Bug Fixes - [#416](https://github.com/ClementTsang/bottom/pull/416): Fixes grouped vs ungrouped modes in the processes widget having inconsistent spacing. diff --git a/src/data_conversion.rs b/src/data_conversion.rs index 871e2126..185aa811 100644 --- a/src/data_conversion.rs +++ b/src/data_conversion.rs @@ -617,7 +617,7 @@ pub fn convert_process_data( process.total_write_bytes, ); - let mem_usage_str = get_decimal_bytes(process.mem_usage_bytes); + let mem_usage_str = get_binary_bytes(process.mem_usage_bytes); let user = { #[cfg(target_family = "unix")] @@ -1236,7 +1236,11 @@ pub fn stringify_process_data( (format!("{:.1}%", process.cpu_percent_usage), None), ( if mem_enabled { - format!("{:.0}{}", process.mem_usage_str.0, process.mem_usage_str.1) + if process.mem_usage_bytes <= GIBI_LIMIT { + format!("{:.0}{}", process.mem_usage_str.0, process.mem_usage_str.1) + } else { + format!("{:.1}{}", process.mem_usage_str.0, process.mem_usage_str.1) + } } else { format!("{:.1}%", process.mem_percent_usage) }, @@ -320,7 +320,7 @@ pub fn handle_force_redraws(app: &mut App) { app.cpu_state.force_update = None; } - // FIXME: [OPT] Prefer reassignment over new vecs? + // FIXME: [OPT] Prefer reassignment over new vectors? if app.mem_state.force_update.is_some() { app.canvas_data.mem_data = convert_mem_data_points(&app.data_collection, app.is_frozen); app.canvas_data.swap_data = convert_swap_data_points(&app.data_collection, app.is_frozen); |