Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change: Add decimal to actual memory usage in proc #449

Merged
merged 3 commits into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions src/data_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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)
},
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down