From 7cd51d15023409f99c7bcaa00fac9af5646e33d1 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Wed, 7 Aug 2024 11:18:03 -0300 Subject: [PATCH 1/4] sysprof: show mark name in waterfall marks This makes is much easier to inspect waterfall marks, since we can spot at a glance which marks are there, without having to hover each mark individually with the cursor to see the tooltip. This helps WebKit profiling in particular, which is a heavy user of marks. --- src/sysprof/sysprof-marks-section.c | 20 ++++++++++++++++++++ src/sysprof/sysprof-marks-section.ui | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/sysprof/sysprof-marks-section.c b/src/sysprof/sysprof-marks-section.c index 9ee2af91..57e52581 100644 --- a/src/sysprof/sysprof-marks-section.c +++ b/src/sysprof/sysprof-marks-section.c @@ -42,6 +42,25 @@ struct _SysprofMarksSection G_DEFINE_FINAL_TYPE (SysprofMarksSection, sysprof_marks_section, SYSPROF_TYPE_SECTION) +static char * +format_mark_label (gpointer unused, + SysprofDocumentMark *mark) +{ + const char *message; + const char *name; + + if (mark == NULL) + return NULL; + + name = sysprof_document_mark_get_name (mark); + message = sysprof_document_mark_get_message (mark); + + if (name && *name && message && *message) + return g_strdup_printf ("%s – %s", name, message); + else + return g_strdup_printf ("%s", name); +} + static char * format_number (gpointer unused, guint number) @@ -74,6 +93,7 @@ sysprof_marks_section_class_init (SysprofMarksSectionClass *klass) gtk_widget_class_bind_template_child (widget_class, SysprofMarksSection, mark_table); gtk_widget_class_bind_template_child (widget_class, SysprofMarksSection, median_column); gtk_widget_class_bind_template_child (widget_class, SysprofMarksSection, summary_column_view); + gtk_widget_class_bind_template_callback (widget_class, format_mark_label); gtk_widget_class_bind_template_callback (widget_class, format_number); g_type_ensure (SYSPROF_TYPE_CHART); diff --git a/src/sysprof/sysprof-marks-section.ui b/src/sysprof/sysprof-marks-section.ui index 2dbe40b3..48a927e8 100644 --- a/src/sysprof/sysprof-marks-section.ui +++ b/src/sysprof/sysprof-marks-section.ui @@ -175,9 +175,9 @@ - + - + From aa15d5f49fbc85f1ddceef004c43759485fffe1d Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Wed, 7 Aug 2024 11:32:29 -0300 Subject: [PATCH 2/4] sysprof: Don't initialize GValue before evaluation GtkExpression infrastructure already initializes the GValue. Fixes a warning introduced by the previous commit. --- src/sysprof/sysprof-time-series.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sysprof/sysprof-time-series.c b/src/sysprof/sysprof-time-series.c index 1b8b1c9b..3935bb90 100644 --- a/src/sysprof/sysprof-time-series.c +++ b/src/sysprof/sysprof-time-series.c @@ -330,7 +330,6 @@ sysprof_time_series_dup_label (SysprofTimeSeries *self, if (!(item = g_list_model_get_item (model, position))) return NULL; - g_value_init (&value, G_TYPE_STRING); gtk_expression_evaluate (self->label_expression, item, &value); return g_value_dup_string (&value); } From 43dd3f50628158ebbc7a5b6e9b03ecbd15bbd1e4 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Wed, 7 Aug 2024 13:36:41 -0300 Subject: [PATCH 3/4] sysprof: Render label outside rect if it doesn't fit This allows reading the mark name even when it is too small to fit any text. --- src/sysprof/sysprof-time-span-layer.c | 31 ++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/sysprof/sysprof-time-span-layer.c b/src/sysprof/sysprof-time-span-layer.c index 7c0884c1..d20842c6 100644 --- a/src/sysprof/sysprof-time-span-layer.c +++ b/src/sysprof/sysprof-time-span-layer.c @@ -216,12 +216,28 @@ sysprof_time_span_layer_snapshot (GtkWidget *widget, gtk_snapshot_append_color (snapshot, color, &rect); } - if (rect.size.width > 20) + if (label != NULL) { + gboolean rect_fits_text; + int right_empty_space; + int label_width; - if (label != NULL) + pango_layout_set_text (layout, label, -1); + pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT); + + pango_layout_get_pixel_size (layout, &label_width, NULL); + + /* If it fits 75% of the text inside the rect, it's enough and + * won't look too busy. + */ + rect_fits_text = ((rect.size.width - 6) / (float) label_width) > 0.75; + right_empty_space = width - (rect.origin.x + rect.size.width) - 6; + + /* Draw inside the rect if the label fits, or if there's not more + * space outside the rect. + */ + if (rect_fits_text || (rect.size.width - 6) > right_empty_space) { - pango_layout_set_text (layout, label, -1); pango_layout_set_width (layout, (rect.size.width - 6) * PANGO_SCALE); gtk_snapshot_save (snapshot); @@ -229,6 +245,15 @@ sysprof_time_span_layer_snapshot (GtkWidget *widget, gtk_snapshot_append_layout (snapshot, layout, label_color); gtk_snapshot_restore (snapshot); } + else if (n_values == 1 && right_empty_space > 20) + { + pango_layout_set_width (layout, right_empty_space * PANGO_SCALE); + + gtk_snapshot_save (snapshot); + gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (rect.origin.x + rect.size.width + 3, layout_y)); + gtk_snapshot_append_layout (snapshot, layout, label_color); + gtk_snapshot_restore (snapshot); + } } } } From 444b4fff7539d2e435611b5513d8cd63440a0279 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Wed, 7 Aug 2024 13:37:27 -0300 Subject: [PATCH 4/4] sysprof: Adjust font size slightly Makes the Waterfall view look better. --- src/sysprof/style.css | 4 ++++ src/sysprof/sysprof-time-span-layer.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/sysprof/style.css b/src/sysprof/style.css index 752d73c7..ea75b44d 100644 --- a/src/sysprof/style.css +++ b/src/sysprof/style.css @@ -95,3 +95,7 @@ timescrubber timecode { flamegraph { font-size: 11px; } + +timespanlayer { + font-size: 10px; +} diff --git a/src/sysprof/sysprof-time-span-layer.c b/src/sysprof/sysprof-time-span-layer.c index d20842c6..6ffd228b 100644 --- a/src/sysprof/sysprof-time-span-layer.c +++ b/src/sysprof/sysprof-time-span-layer.c @@ -497,6 +497,8 @@ sysprof_time_span_layer_class_init (SysprofTimeSpanLayerClass *klass) (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS)); g_object_class_install_properties (object_class, N_PROPS, properties); + + gtk_widget_class_set_css_name (widget_class, "timespanlayer"); } static void