mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 07:00:53 +00:00
libsysprof: simplify summary generation
This still doesn't actually do anything, just the scaffolding.
This commit is contained in:
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "sysprof-callgraph-private.h"
|
#include "sysprof-callgraph-private.h"
|
||||||
#include "sysprof-callgraph-frame-private.h"
|
#include "sysprof-callgraph-frame-private.h"
|
||||||
#include "sysprof-category-summary.h"
|
#include "sysprof-category-summary-private.h"
|
||||||
#include "sysprof-enums.h"
|
#include "sysprof-enums.h"
|
||||||
#include "sysprof-symbol-private.h"
|
#include "sysprof-symbol-private.h"
|
||||||
#include "sysprof-document-bitset-index-private.h"
|
#include "sysprof-document-bitset-index-private.h"
|
||||||
@ -510,13 +510,17 @@ sysprof_callgraph_frame_get_category (SysprofCallgraphFrame *self)
|
|||||||
return SYSPROF_CALLGRAPH_CATEGORY_UNCATEGORIZED;
|
return SYSPROF_CALLGRAPH_CATEGORY_UNCATEGORIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct _Summary
|
||||||
|
{
|
||||||
|
guint64 count;
|
||||||
|
} Summary;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
summarize_node (const SysprofCallgraphNode *node,
|
summarize_node (const SysprofCallgraphNode *node,
|
||||||
GListStore *store,
|
Summary *summaries)
|
||||||
GHashTable *category_to_summary)
|
|
||||||
{
|
{
|
||||||
for (const SysprofCallgraphNode *iter = node->children; iter; iter = iter->next)
|
for (const SysprofCallgraphNode *iter = node->children; iter; iter = iter->next)
|
||||||
summarize_node (iter, store, category_to_summary);
|
summarize_node (iter, summaries);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -526,17 +530,36 @@ sysprof_callgraph_frame_summarize (GTask *task,
|
|||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
SysprofCallgraphFrame *self = source_object;
|
SysprofCallgraphFrame *self = source_object;
|
||||||
g_autoptr(GHashTable) category_to_summary = NULL;
|
g_autofree Summary *summaries = NULL;
|
||||||
g_autoptr(GListStore) store = NULL;
|
g_autoptr(GListStore) store = NULL;
|
||||||
|
guint64 total = 0;
|
||||||
|
|
||||||
g_assert (G_IS_TASK (task));
|
g_assert (G_IS_TASK (task));
|
||||||
g_assert (SYSPROF_IS_CALLGRAPH_FRAME (self));
|
g_assert (SYSPROF_IS_CALLGRAPH_FRAME (self));
|
||||||
g_assert (SYSPROF_IS_CALLGRAPH (task_data));
|
g_assert (SYSPROF_IS_CALLGRAPH (task_data));
|
||||||
|
|
||||||
store = g_list_store_new (G_TYPE_OBJECT);
|
summaries = g_new0 (Summary, SYSPROF_CALLGRAPH_CATEGORY_LAST);
|
||||||
category_to_summary = g_hash_table_new (NULL, NULL);
|
summarize_node (self->node, summaries);
|
||||||
|
|
||||||
summarize_node (self->node, store, category_to_summary);
|
store = g_list_store_new (G_TYPE_OBJECT);
|
||||||
|
|
||||||
|
for (guint i = 0; i < SYSPROF_CALLGRAPH_CATEGORY_LAST; i++)
|
||||||
|
total += summaries[i].count;
|
||||||
|
|
||||||
|
for (guint i = 0; i < SYSPROF_CALLGRAPH_CATEGORY_LAST; i++)
|
||||||
|
{
|
||||||
|
g_autoptr(SysprofCategorySummary) summary = NULL;
|
||||||
|
|
||||||
|
if (summaries[i].count == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
summary = g_object_new (SYSPROF_TYPE_CATEGORY_SUMMARY, NULL);
|
||||||
|
summary->category = i;
|
||||||
|
summary->total = total;
|
||||||
|
summary->count = summaries[i].count;
|
||||||
|
|
||||||
|
g_list_store_append (store, summary);
|
||||||
|
}
|
||||||
|
|
||||||
g_task_return_pointer (task, g_steal_pointer (&store), g_object_unref);
|
g_task_return_pointer (task, g_steal_pointer (&store), g_object_unref);
|
||||||
}
|
}
|
||||||
|
|||||||
35
src/libsysprof/sysprof-category-summary-private.h
Normal file
35
src/libsysprof/sysprof-category-summary-private.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* sysprof-category-summary-private.h
|
||||||
|
*
|
||||||
|
* Copyright 2023 Christian Hergert <chergert@redhat.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "sysprof-category-summary.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
struct _SysprofCategorySummary
|
||||||
|
{
|
||||||
|
GObject parent_instance;
|
||||||
|
SysprofCallgraphCategory category;
|
||||||
|
guint64 count;
|
||||||
|
guint64 total;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
@ -20,17 +20,9 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysprof-category-summary.h"
|
#include "sysprof-category-summary-private.h"
|
||||||
#include "sysprof-enums.h"
|
#include "sysprof-enums.h"
|
||||||
|
|
||||||
struct _SysprofCategorySummary
|
|
||||||
{
|
|
||||||
GObject parent_instance;
|
|
||||||
SysprofCallgraphCategory category;
|
|
||||||
guint64 count;
|
|
||||||
guint64 total;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_CATEGORY,
|
PROP_CATEGORY,
|
||||||
|
|||||||
Reference in New Issue
Block a user