From e03b1ec8b7da6f928cdd769a1c230d74f038c135 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 15 May 2019 16:39:02 -0700 Subject: [PATCH] libsysprof-ui: add more capture details --- src/libsysprof-ui/sysprof-capture-view.c | 11 +- src/libsysprof-ui/sysprof-details-view.c | 38 ++++++ src/libsysprof-ui/ui/sysprof-details-view.ui | 131 ++++++++++++++----- 3 files changed, 146 insertions(+), 34 deletions(-) diff --git a/src/libsysprof-ui/sysprof-capture-view.c b/src/libsysprof-ui/sysprof-capture-view.c index 325b673b..794091cc 100644 --- a/src/libsysprof-ui/sysprof-capture-view.c +++ b/src/libsysprof-ui/sysprof-capture-view.c @@ -221,6 +221,7 @@ sysprof_capture_view_scan_worker (GTask *task, SysprofCaptureReader *reader = task_data; SysprofCaptureFeatures features = {0}; SysprofCaptureFrame frame; + SysprofCaptureStat st_buf = {0}; g_assert (SYSPROF_IS_CAPTURE_VIEW (self)); g_assert (G_IS_TASK (task)); @@ -235,6 +236,10 @@ sysprof_capture_view_scan_worker (GTask *task, gint64 begin_time = frame.time; gint64 end_time = G_MININT64; + g_assert (frame.type < G_N_ELEMENTS (st_buf.frame_count)); + + st_buf.frame_count[frame.type]++; + if (frame.type == SYSPROF_CAPTURE_FRAME_MARK) { const SysprofCaptureMark *mark; @@ -265,6 +270,8 @@ sysprof_capture_view_scan_worker (GTask *task, features.end_time = end_time; } + sysprof_capture_reader_set_stat (reader, &st_buf); + if (!g_task_return_error_if_cancelled (task)) { priv->features = features; @@ -428,6 +435,8 @@ sysprof_capture_view_load_scan_cb (GObject *object, g_object_ref (task)); } + sysprof_details_view_set_reader (priv->details_view, priv->reader); + if (state->n_active == 0) g_task_return_boolean (task, TRUE); } @@ -488,8 +497,6 @@ sysprof_capture_view_real_load_async (SysprofCaptureView *self, cancellable, sysprof_capture_view_load_scan_cb, g_steal_pointer (&task)); - - sysprof_details_view_set_reader (priv->details_view, reader); } static gboolean diff --git a/src/libsysprof-ui/sysprof-details-view.c b/src/libsysprof-ui/sysprof-details-view.c index d216563b..4ed629ea 100644 --- a/src/libsysprof-ui/sysprof-details-view.c +++ b/src/libsysprof-ui/sysprof-details-view.c @@ -26,10 +26,17 @@ #include "sysprof-details-view.h" +#define NSEC_PER_SEC (G_USEC_PER_SEC * 1000L) + struct _SysprofDetailsView { GtkBin parent_instance; + GtkLabel *duration; GtkLabel *filename; + GtkLabel *forks; + GtkLabel *marks; + GtkLabel *processes; + GtkLabel *samples; GtkLabel *start_time; }; @@ -50,7 +57,12 @@ sysprof_details_view_class_init (SysprofDetailsViewClass *klass) object_class->finalize = sysprof_details_view_finalize; gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-details-view.ui"); + gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, duration); gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, filename); + gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, forks); + gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, marks); + gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, processes); + gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, samples); gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, start_time); } @@ -72,10 +84,14 @@ sysprof_details_view_set_reader (SysprofDetailsView *self, { g_autoptr(GDateTime) dt = NULL; g_autoptr(GDateTime) local = NULL; + g_autofree gchar *duration_str = NULL; const gchar *filename; const gchar *capture_at; + SysprofCaptureStat st_buf; + gint64 duration; g_return_if_fail (SYSPROF_IS_DETAILS_VIEW (self)); + g_return_if_fail (reader != NULL); if (!(filename = sysprof_capture_reader_get_filename (reader))) filename = _("Memory Capture"); @@ -88,4 +104,26 @@ sysprof_details_view_set_reader (SysprofDetailsView *self, g_autofree gchar *str = g_date_time_format (local, "%x %X"); gtk_label_set_label (self->start_time, str); } + + duration = sysprof_capture_reader_get_end_time (reader) - + sysprof_capture_reader_get_start_time (reader); + duration_str = g_strdup_printf (_("%0.4lf seconds"), duration / (gdouble)NSEC_PER_SEC); + gtk_label_set_label (self->duration, duration_str); + + if (sysprof_capture_reader_get_stat (reader, &st_buf)) + { +#define SET_FRAME_COUNT(field, TYPE) \ + G_STMT_START { \ + g_autofree gchar *str = NULL; \ + str = g_strdup_printf ("%"G_GSIZE_FORMAT, st_buf.frame_count[TYPE]); \ + gtk_label_set_label (self->field, str); \ + } G_STMT_END + + SET_FRAME_COUNT (samples, SYSPROF_CAPTURE_FRAME_SAMPLE); + SET_FRAME_COUNT (marks, SYSPROF_CAPTURE_FRAME_MARK); + SET_FRAME_COUNT (processes, SYSPROF_CAPTURE_FRAME_PROCESS); + SET_FRAME_COUNT (forks, SYSPROF_CAPTURE_FRAME_FORK); + +#undef SET_FRAME_COUNT + } } diff --git a/src/libsysprof-ui/ui/sysprof-details-view.ui b/src/libsysprof-ui/ui/sysprof-details-view.ui index a828c286..f4863a44 100644 --- a/src/libsysprof-ui/ui/sysprof-details-view.ui +++ b/src/libsysprof-ui/ui/sysprof-details-view.ui @@ -32,11 +32,6 @@ - - False - True - 0 - @@ -48,17 +43,69 @@ - - False - True - 1 - + + + + True + False + Duration + 1 + + + + + + 12 + True + False + Samples Captured + 1 + + + + + + True + False + Marks Captured + 1 + + + + + + True + False + Processes Captured + 1 + + + + + + True + False + Forks Captured + 1 + + - True - True + start 0 + true + true @@ -74,11 +121,6 @@ start 0 - - False - True - 0 - @@ -87,25 +129,50 @@ start 0 - - False - True - 1 - + + + + True + False + 0 + + + + + 12 + True + False + start + 0 + + + + + True + False + start + 0 + + + + + True + False + start + 0 + + + + + True + False + start + 0 + - - False - True - 1 - - - False - True - 1 -