libsysprof-analyze: add duration property to process

This is a bit easier to bind to a chart since we need the expression as
a duration rather than the end time.
This commit is contained in:
Christian Hergert
2023-07-06 15:33:56 -07:00
parent a999a8a455
commit b3f8b45b16
2 changed files with 24 additions and 0 deletions

View File

@ -38,6 +38,7 @@ struct _SysprofDocumentProcessClass
enum {
PROP_0,
PROP_COMMAND_LINE,
PROP_DURATION,
PROP_EXIT_TIME,
N_PROPS
};
@ -70,6 +71,10 @@ sysprof_document_process_get_property (GObject *object,
g_value_set_string (value, sysprof_document_process_get_command_line (self));
break;
case PROP_DURATION:
g_value_set_int64 (value, sysprof_document_process_get_duration (self));
break;
case PROP_EXIT_TIME:
g_value_set_int64 (value, sysprof_document_process_get_exit_time (self));
break;
@ -92,6 +97,11 @@ sysprof_document_process_class_init (SysprofDocumentProcessClass *klass)
NULL,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
properties [PROP_DURATION] =
g_param_spec_int64 ("duration", NULL, NULL,
G_MININT64, G_MAXINT64, 0,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
properties [PROP_EXIT_TIME] =
g_param_spec_int64 ("exit-time", NULL, NULL,
G_MININT64, G_MAXINT64, 0,
@ -189,3 +199,15 @@ sysprof_document_process_get_exit_time (SysprofDocumentProcess *self)
return MAX (t, exit_time);
}
gint64
sysprof_document_process_get_duration (SysprofDocumentProcess *self)
{
gint64 t;
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_PROCESS (self), 0);
t = sysprof_document_frame_get_time (SYSPROF_DOCUMENT_FRAME (self));
return sysprof_document_process_get_exit_time (self) - t;
}

View File

@ -41,6 +41,8 @@ const char *sysprof_document_process_get_command_line (SysprofDocumentProcess *s
SYSPROF_AVAILABLE_IN_ALL
gint64 sysprof_document_process_get_exit_time (SysprofDocumentProcess *self);
SYSPROF_AVAILABLE_IN_ALL
gint64 sysprof_document_process_get_duration (SysprofDocumentProcess *self);
SYSPROF_AVAILABLE_IN_ALL
GListModel *sysprof_document_process_list_memory_maps (SysprofDocumentProcess *self);
SYSPROF_AVAILABLE_IN_ALL
GListModel *sysprof_document_process_list_mounts (SysprofDocumentProcess *self);