From b3f8b45b16e36236b211d08c703adbfe1d01de77 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 6 Jul 2023 15:33:56 -0700 Subject: [PATCH] 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. --- .../sysprof-document-process.c | 22 +++++++++++++++++++ .../sysprof-document-process.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/libsysprof-analyze/sysprof-document-process.c b/src/libsysprof-analyze/sysprof-document-process.c index 9ff93209..9dc8c4ca 100644 --- a/src/libsysprof-analyze/sysprof-document-process.c +++ b/src/libsysprof-analyze/sysprof-document-process.c @@ -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; +} diff --git a/src/libsysprof-analyze/sysprof-document-process.h b/src/libsysprof-analyze/sysprof-document-process.h index 78c67a9b..4c498968 100644 --- a/src/libsysprof-analyze/sysprof-document-process.h +++ b/src/libsysprof-analyze/sysprof-document-process.h @@ -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);