From 352f1b20381dc76dce7adc006756d2f16e99fbbe Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 25 Aug 2023 11:27:55 -0700 Subject: [PATCH] sysprof: include sample count and percentage in tooltip --- src/sysprof/sysprof-flame-graph.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/sysprof/sysprof-flame-graph.c b/src/sysprof/sysprof-flame-graph.c index c67b67f5..0feff195 100644 --- a/src/sysprof/sysprof-flame-graph.c +++ b/src/sysprof/sysprof-flame-graph.c @@ -309,6 +309,13 @@ sysprof_flame_graph_query_tooltip (GtkWidget *widget, { g_autoptr(GString) string = g_string_new (NULL); SysprofSymbol *symbol = rect->node->summary->symbol; + SysprofCallgraphNode *root = rect->node; + guint64 weight = 0; + + while (root->parent) + root = root->parent; + for (SysprofCallgraphNode *child = root->children; child; child = child->next) + weight += child->count; g_string_append (string, symbol->name); @@ -318,6 +325,15 @@ sysprof_flame_graph_query_tooltip (GtkWidget *widget, if (symbol->binary_path && symbol->binary_path[0]) g_string_append_printf (string, "\n%s", symbol->binary_path); + g_string_append_c (string, '\n'); + + if (rect->node != root) + g_string_append_printf (string, "%'u samples, %6.2lf%%", + rect->node->count, + rect->node->count / (double)weight * 100.); + else + g_string_append_printf (string, "%'u samples", (guint)weight); + gtk_tooltip_set_text (tooltip, string->str); return TRUE;