]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4770: profiler: add note for total percentage for profiler_dump
authorRishabh Choudhary (rishacho) <rishacho@cisco.com>
Mon, 9 Jun 2025 06:37:27 +0000 (06:37 +0000)
committerShanmugam S (shanms) <shanms@cisco.com>
Mon, 9 Jun 2025 06:37:27 +0000 (06:37 +0000)
Merge in SNORT/snort3 from ~RISHACHO/snort3:cpu_profiler_warn_msg to master

Squashed commit of the following:

commit d23e9ce41dae05647dab0221969e20399660a91e
Author: Rishabh Choudhary <rishacho@cisco.com>
Date:   Thu Jun 5 15:01:01 2025 +0530

    profiler: add note for total percentage for profiler_dump

src/profiler/profiler_printer.h
src/profiler/time_profiler.cc

index 8082116a59f261f275c9234fb81c9d9f4445864b..8e30b9e116faaf84bdb89f6f6d94d37934d33999 100644 (file)
@@ -170,6 +170,11 @@ public:
         print_t(ss.str().c_str());
     }
 
+    float get_total()
+    {
+        return total;
+    }
+
 private:
     const StatsTable::Field* fields;
     const PrintFn print;
index bc45ffff4d408e939bcae15004b0176b6c0b7e11..89a1fdf1b9c7994def2264087ca0e9f96be86980 100644 (file)
@@ -22,6 +22,8 @@
 #include "config.h"
 #endif
 
+#include <cmath>
+
 #include "time_profiler.h"
 
 #include "profiler_nodes.h"
@@ -184,6 +186,9 @@ void print_time_profiler_stats(ProfilerNodeMap& nodes, const TimeProfilerConfig&
 
     ProfilerPrinter<time_stats::View> printer(time_stats::fields, time_stats::print_fn, sorter, printer_t);
     printer.print_table(s_time_table_title, root, config.count, config.max_depth);
+
+    if (std::roundf(printer.get_total()) > 100.0f)
+        LogRespond(ctrlcon, "Note: Total time for a module includes time spent in submodules. Total percentage may exceed 100\n");
 }
 
 #ifdef UNIT_TEST