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).
This commit is contained in:
Clement Tsang 2021-04-09 15:43:34 -04:00 committed by GitHub
parent e824eafdb2
commit edb29a43b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -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.

View File

@ -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)
},

View File

@ -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);