Skip to content

Commit

Permalink
Add option to accumulate a child's resources in parent in tree-view
Browse files Browse the repository at this point in the history
  • Loading branch information
imwints committed Sep 14, 2023
1 parent 2c3ac48 commit 6027ced
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/btop_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ namespace Config {

{"proc_filter_kernel", "#* (Linux) Filter processes tied to the Linux kernel(similar behavior to htop)."},

{"proc_aggregate", "#* In tree-view, always accumulate child process resources in the parent process."},

{"cpu_graph_upper", "#* Sets the CPU stat shown in upper half of the CPU graph, \"total\" is always available.\n"
"#* Select from a list of detected attributes from the options menu."},

Expand Down Expand Up @@ -268,6 +270,7 @@ namespace Config {
{"lowcolor", false},
{"show_detailed", false},
{"proc_filtering", false},
{"proc_aggregate", false},
};
unordered_flat_map<std::string_view, bool> boolsTmp;

Expand Down
5 changes: 5 additions & 0 deletions src/btop_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ namespace Menu {
"Set true to show processes grouped by",
"parents with lines drawn between parent",
"and child process."},
{"proc_aggregate",
"Aggregate child's resources in parent.",
"",
"In tree-view, include all child resources",
"with the parent even while expanded."},
{"proc_colors",
"Enable colors in process view.",
"",
Expand Down
7 changes: 7 additions & 0 deletions src/btop_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ tab-size = 4

#include <ranges>

#include "btop_config.hpp"
#include "btop_shared.hpp"
#include "btop_tools.hpp"

Expand Down Expand Up @@ -156,6 +157,12 @@ namespace Proc {
filter_found++;
p.filtered = true;
}
else if (Config::getB("proc_aggregate")) {
cur_proc.cpu_p += p.cpu_p;
cur_proc.cpu_c += p.cpu_c;
cur_proc.mem += p.mem;
cur_proc.threads += p.threads;
}
}
if (collapsed or filtering) {
return;
Expand Down

0 comments on commit 6027ced

Please sign in to comment.