From 6027cedd424e963bc6fe9017252ed4f1c9f8634b Mon Sep 17 00:00:00 2001 From: nobounce Date: Thu, 14 Sep 2023 23:27:05 +0200 Subject: [PATCH] Add option to accumulate a child's resources in parent in tree-view --- src/btop_config.cpp | 3 +++ src/btop_menu.cpp | 5 +++++ src/btop_shared.cpp | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/src/btop_config.cpp b/src/btop_config.cpp index 6010189..fc71e41 100644 --- a/src/btop_config.cpp +++ b/src/btop_config.cpp @@ -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."}, @@ -268,6 +270,7 @@ namespace Config { {"lowcolor", false}, {"show_detailed", false}, {"proc_filtering", false}, + {"proc_aggregate", false}, }; unordered_flat_map boolsTmp; diff --git a/src/btop_menu.cpp b/src/btop_menu.cpp index c9dfbdc..663ac4f 100644 --- a/src/btop_menu.cpp +++ b/src/btop_menu.cpp @@ -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.", "", diff --git a/src/btop_shared.cpp b/src/btop_shared.cpp index e5c9027..98c24ce 100644 --- a/src/btop_shared.cpp +++ b/src/btop_shared.cpp @@ -18,6 +18,7 @@ tab-size = 4 #include +#include "btop_config.hpp" #include "btop_shared.hpp" #include "btop_tools.hpp" @@ -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;