From 5c2a1f20164a2981700aa89bad7f3b694dabecfa Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 21 Jul 2023 09:46:12 -0700 Subject: [PATCH] libsysprof: fix cost accounting for categories We don't want to derive the total count from each summary, but instead the total count of nodes w/ is_toplevel set. --- src/libsysprof/sysprof-callgraph-frame.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libsysprof/sysprof-callgraph-frame.c b/src/libsysprof/sysprof-callgraph-frame.c index 9e493034..38c5c504 100644 --- a/src/libsysprof/sysprof-callgraph-frame.c +++ b/src/libsysprof/sysprof-callgraph-frame.c @@ -525,6 +525,9 @@ summarize_node (const SysprofCallgraphNode *node, { gboolean seen[SYSPROF_CALLGRAPH_CATEGORY_LAST] = {0}; + /* Track total count in 0 */ + summaries[0].count += node->count; + seen[node->category & 0xFF] = TRUE; summaries[node->category & 0xFF].count += node->count; @@ -561,11 +564,9 @@ sysprof_callgraph_frame_summarize (GTask *task, summarize_node (self->node, summaries); store = g_list_store_new (G_TYPE_OBJECT); + total = summaries[0].count; - for (guint i = 0; i < SYSPROF_CALLGRAPH_CATEGORY_LAST; i++) - total += summaries[i].count; - - for (guint i = 0; i < SYSPROF_CALLGRAPH_CATEGORY_LAST; i++) + for (guint i = 1; i < SYSPROF_CALLGRAPH_CATEGORY_LAST; i++) { g_autoptr(SysprofCategorySummary) summary = NULL;