sysprof: add UI to toggle merge-similar-processes flags

Related #93
This commit is contained in:
Christian Hergert
2023-08-28 13:32:27 -07:00
parent cdfae5f7b9
commit a60bc04de2
8 changed files with 103 additions and 29 deletions

View File

@ -58,6 +58,7 @@ struct _SysprofCallgraphView
guint ignore_process_0 : 1;
guint include_threads : 1;
guint left_heavy : 1;
guint merge_similar_processes : 1;
};
struct _SysprofCallgraphViewClass

View File

@ -39,6 +39,7 @@ enum {
PROP_IGNORE_PROCESS_0,
PROP_INCLUDE_THREADS,
PROP_LEFT_HEAVY,
PROP_MERGE_SIMILAR_PROCESSES,
PROP_TRACEABLES,
PROP_UTILITY_SUMMARY,
PROP_UTILITY_TRACEABLES,
@ -399,6 +400,10 @@ sysprof_callgraph_view_get_property (GObject *object,
g_value_set_boolean (value, sysprof_callgraph_view_get_left_heavy (self));
break;
case PROP_MERGE_SIMILAR_PROCESSES:
g_value_set_boolean (value, sysprof_callgraph_view_get_merge_similar_processes (self));
break;
case PROP_TRACEABLES:
g_value_set_object (value, sysprof_callgraph_view_get_traceables (self));
break;
@ -454,6 +459,10 @@ sysprof_callgraph_view_set_property (GObject *object,
sysprof_callgraph_view_set_left_heavy (self, g_value_get_boolean (value));
break;
case PROP_MERGE_SIMILAR_PROCESSES:
sysprof_callgraph_view_set_merge_similar_processes (self, g_value_get_boolean (value));
break;
case PROP_TRACEABLES:
sysprof_callgraph_view_set_traceables (self, g_value_get_object (value));
break;
@ -513,6 +522,11 @@ sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass)
FALSE,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
properties[PROP_MERGE_SIMILAR_PROCESSES] =
g_param_spec_boolean ("merge-similar-processes", NULL, NULL,
FALSE,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
properties[PROP_TRACEABLES] =
g_param_spec_object ("traceables", NULL, NULL,
G_TYPE_LIST_MODEL,
@ -697,6 +711,9 @@ sysprof_callgraph_view_reload (SysprofCallgraphView *self)
if (self->left_heavy)
flags |= SYSPROF_CALLGRAPH_FLAGS_LEFT_HEAVY;
if (self->merge_similar_processes)
flags |= SYSPROF_CALLGRAPH_FLAGS_MERGE_SIMILAR_PROCESSES;
sysprof_document_callgraph_async (self->document,
flags,
self->traceables,
@ -974,3 +991,27 @@ sysprof_callgraph_view_set_left_heavy (SysprofCallgraphView *self,
sysprof_callgraph_view_queue_reload (self);
}
}
gboolean
sysprof_callgraph_view_get_merge_similar_processes (SysprofCallgraphView *self)
{
g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self), FALSE);
return self->merge_similar_processes;
}
void
sysprof_callgraph_view_set_merge_similar_processes (SysprofCallgraphView *self,
gboolean merge_similar_processes)
{
g_return_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self));
merge_similar_processes = !!merge_similar_processes;
if (self->merge_similar_processes != merge_similar_processes)
{
self->merge_similar_processes = merge_similar_processes;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MERGE_SIMILAR_PROCESSES]);
sysprof_callgraph_view_queue_reload (self);
}
}

View File

@ -35,32 +35,35 @@ G_BEGIN_DECLS
typedef struct _SysprofCallgraphView SysprofCallgraphView;
typedef struct _SysprofCallgraphViewClass SysprofCallgraphViewClass;
GType sysprof_callgraph_view_get_type (void) G_GNUC_CONST;
SysprofCallgraph *sysprof_callgraph_view_get_callgraph (SysprofCallgraphView *self);
SysprofDocument *sysprof_callgraph_view_get_document (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_document (SysprofCallgraphView *self,
SysprofDocument *document);
GListModel *sysprof_callgraph_view_get_traceables (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_traceables (SysprofCallgraphView *self,
GListModel *model);
gboolean sysprof_callgraph_view_get_bottom_up (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_bottom_up (SysprofCallgraphView *self,
gboolean bottom_up);
gboolean sysprof_callgraph_view_get_categorize_frames (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_categorize_frames (SysprofCallgraphView *self,
gboolean categorize_frames);
gboolean sysprof_callgraph_view_get_ignore_process_0 (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_ignore_process_0 (SysprofCallgraphView *self,
gboolean ignore_process_0);
gboolean sysprof_callgraph_view_get_include_threads (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_include_threads (SysprofCallgraphView *self,
gboolean include_threads);
gboolean sysprof_callgraph_view_get_hide_system_libraries (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_hide_system_libraries (SysprofCallgraphView *self,
gboolean hide_system_libraries);
gboolean sysprof_callgraph_view_get_left_heavy (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_left_heavy (SysprofCallgraphView *self,
gboolean left_heavy);
GType sysprof_callgraph_view_get_type (void) G_GNUC_CONST;
SysprofCallgraph *sysprof_callgraph_view_get_callgraph (SysprofCallgraphView *self);
SysprofDocument *sysprof_callgraph_view_get_document (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_document (SysprofCallgraphView *self,
SysprofDocument *document);
GListModel *sysprof_callgraph_view_get_traceables (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_traceables (SysprofCallgraphView *self,
GListModel *model);
gboolean sysprof_callgraph_view_get_bottom_up (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_bottom_up (SysprofCallgraphView *self,
gboolean bottom_up);
gboolean sysprof_callgraph_view_get_categorize_frames (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_categorize_frames (SysprofCallgraphView *self,
gboolean categorize_frames);
gboolean sysprof_callgraph_view_get_ignore_process_0 (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_ignore_process_0 (SysprofCallgraphView *self,
gboolean ignore_process_0);
gboolean sysprof_callgraph_view_get_include_threads (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_include_threads (SysprofCallgraphView *self,
gboolean include_threads);
gboolean sysprof_callgraph_view_get_hide_system_libraries (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_hide_system_libraries (SysprofCallgraphView *self,
gboolean hide_system_libraries);
gboolean sysprof_callgraph_view_get_left_heavy (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_left_heavy (SysprofCallgraphView *self,
gboolean left_heavy);
gboolean sysprof_callgraph_view_get_merge_similar_processes (SysprofCallgraphView *self);
void sysprof_callgraph_view_set_merge_similar_processes (SysprofCallgraphView *self,
gboolean merge_similar_processes);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofCallgraphView, g_object_unref)

View File

@ -275,6 +275,10 @@
<attribute name="label" translatable="yes">Ignore Process 0</attribute>
<attribute name="action">win.callgraph.ignore-process-0</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Merge Similar Processes</attribute>
<attribute name="action">win.callgraph.merge-similar-processes</attribute>
</item>
</section>
</menu>
</interface>

View File

@ -109,6 +109,11 @@
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<binding name="merge-similar-processes">
<lookup name="merge-similar-processes" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<binding name="categorize-frames">
<lookup name="categorize-frames" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>

View File

@ -41,23 +41,25 @@ struct _SysprofSession
guint bottom_up : 1;
guint categorize_frames : 1;
guint hide_system_libraries : 1;
guint ignore_process_0 : 1;
guint include_threads : 1;
guint left_heavy : 1;
guint hide_system_libraries : 1;
guint merge_similar_processes : 1;
};
enum {
PROP_0,
PROP_BOTTOM_UP,
PROP_CATEGORIZE_FRAMES,
PROP_DOCUMENT,
PROP_DOCUMENT_TIME,
PROP_FILTER,
PROP_LEFT_HEAVY,
PROP_HIDE_SYSTEM_LIBRARIES,
PROP_IGNORE_PROCESS_0,
PROP_INCLUDE_THREADS,
PROP_CATEGORIZE_FRAMES,
PROP_LEFT_HEAVY,
PROP_MERGE_SIMILAR_PROCESSES,
PROP_SELECTED_TIME,
PROP_SELECTED_TIME_AXIS,
PROP_VISIBLE_TIME,
@ -162,6 +164,10 @@ sysprof_session_get_property (GObject *object,
g_value_set_boolean (value, self->left_heavy);
break;
case PROP_MERGE_SIMILAR_PROCESSES:
g_value_set_boolean (value, self->merge_similar_processes);
break;
case PROP_SELECTED_TIME:
g_value_set_boxed (value, sysprof_session_get_selected_time (self));
break;
@ -221,6 +227,10 @@ sysprof_session_set_property (GObject *object,
self->left_heavy = g_value_get_boolean (value);
break;
case PROP_MERGE_SIMILAR_PROCESSES:
self->merge_similar_processes = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@ -280,6 +290,11 @@ sysprof_session_class_init (SysprofSessionClass *klass)
FALSE,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
properties [PROP_MERGE_SIMILAR_PROCESSES] =
g_param_spec_boolean ("merge-similar-processes", NULL, NULL,
FALSE,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
properties [PROP_SELECTED_TIME] =
g_param_spec_boxed ("selected-time", NULL, NULL,
SYSPROF_TYPE_TIME_SPAN,

View File

@ -225,6 +225,7 @@ sysprof_window_set_document (SysprofWindow *self,
"ignore-process-0",
"include-threads",
"left-heavy",
"merge-similar-processes",
};
g_autofree char *title = NULL;
g_autofree char *full_title = NULL;

View File

@ -381,6 +381,10 @@
<attribute name="label" translatable="yes">Ignore Process 0</attribute>
<attribute name="action">win.callgraph.ignore-process-0</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Merge Similar Processes</attribute>
<attribute name="action">win.callgraph.merge-similar-processes</attribute>
</item>
</section>
<section>
<attribute name="label" translatable="yes">Flamegraph</attribute>