libsysprof-analyze: add aggregate marks by group

This is handy so that we can show aggregate results in other places without
using a FlattenListModel which can mess up event ordering.
This commit is contained in:
Christian Hergert
2023-07-05 16:07:07 -07:00
parent af39c9611c
commit 2e0f046390
2 changed files with 41 additions and 1 deletions

View File

@ -1311,7 +1311,7 @@ sysprof_document_list_traceables (SysprofDocument *self)
* Gets a #GListModel containing #SysprofDocumentMark found within
* the #SysprofDocument.
*
* Returns: (transfer full): a #GListModel of #SysprofDocumentAllocation
* Returns: (transfer full): a #GListModel of #SysprofDocumentMark
*/
GListModel *
sysprof_document_list_marks (SysprofDocument *self)
@ -1321,6 +1321,43 @@ sysprof_document_list_marks (SysprofDocument *self)
return _sysprof_document_bitset_index_new (G_LIST_MODEL (self), self->marks);
}
/**
* sysprof_document_list_marks_by_group:
* @self: a #SysprofDocument
* @group: the name of the group
*
* Gets a #GListModel containing #SysprofDocumentMark found within
* the #SysprofDocument which are part of @group.
*
* Returns: (transfer full): a #GListModel of #SysprofDocumentMark
*/
GListModel *
sysprof_document_list_marks_by_group (SysprofDocument *self,
const char *group)
{
g_autoptr(EggBitset) bitset = NULL;
GHashTable *names;
g_return_val_if_fail (SYSPROF_IS_DOCUMENT (self), NULL);
g_return_val_if_fail (group != NULL, NULL);
bitset = egg_bitset_new_empty ();
if ((names = g_hash_table_lookup (self->mark_groups, group)))
{
GHashTableIter iter;
const char *name;
EggBitset *indices;
g_hash_table_iter_init (&iter, names);
while (g_hash_table_iter_next (&iter, (gpointer *)&name, (gpointer *)&indices))
egg_bitset_union (bitset, indices);
}
return _sysprof_document_bitset_index_new (G_LIST_MODEL (self), bitset);
}
/**
* sysprof_document_list_allocations:
* @self: a #SysprofDocument

View File

@ -63,6 +63,9 @@ GListModel *sysprof_document_list_counters (SysprofDocume
SYSPROF_AVAILABLE_IN_ALL
GListModel *sysprof_document_list_marks (SysprofDocument *self);
SYSPROF_AVAILABLE_IN_ALL
GListModel *sysprof_document_list_marks_by_group (SysprofDocument *self,
const char *group);
SYSPROF_AVAILABLE_IN_ALL
GListModel *sysprof_document_catalog_marks (SysprofDocument *self);
SYSPROF_AVAILABLE_IN_ALL
SysprofDocumentCounter