[gtk/matthiasc/for-master: 6/6] Add profiler support for css validation
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 6/6] Add profiler support for css validation
- Date: Tue, 21 Jan 2020 02:56:11 +0000 (UTC)
commit a350c2452af517dff4a94ac3c0aef7ebbeba8962
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jan 20 20:08:41 2020 -0500
Add profiler support for css validation
Push numbers about css validation and style creation
to sysprof.
gtk/gtkcssnode.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
---
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 4fe350d5ff..72de82941e 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -27,6 +27,7 @@
#include "gtksettingsprivate.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
+#include "gdkprofilerprivate.h"
/*
* CSS nodes are the backbone of the GtkStyleContext implementation and
@@ -122,6 +123,13 @@ gtk_css_node_get_style_provider_or_null (GtkCssNode *cssnode)
return GTK_CSS_NODE_GET_CLASS (cssnode)->get_style_provider (cssnode);
}
+#ifdef G_ENABLE_DEBUG
+static int invalidated_nodes;
+static int created_styles;
+static guint invalidated_nodes_counter;
+static guint created_styles_counter;
+#endif
+
static void
gtk_css_node_set_invalid (GtkCssNode *node,
gboolean invalid)
@@ -131,6 +139,11 @@ gtk_css_node_set_invalid (GtkCssNode *node,
node->invalid = invalid;
+#ifdef G_ENABLE_DEBUG
+ if (invalid)
+ invalidated_nodes++;
+#endif
+
if (node->visible)
{
if (node->parent)
@@ -369,6 +382,10 @@ gtk_css_node_create_style (GtkCssNode *cssnode,
if (style)
return g_object_ref (style);
+#ifdef G_ENABLE_DEBUG
+ created_styles++;
+#endif
+
parent = cssnode->parent ? cssnode->parent->style : NULL;
if (change & GTK_CSS_CHANGE_NEEDS_RECOMPUTE)
@@ -665,6 +682,14 @@ gtk_css_node_class_init (GtkCssNodeClass *klass)
| G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, NUM_PROPERTIES, cssnode_properties);
+
+#ifdef G_ENABLE_DEBUG
+ if (invalidated_nodes_counter == 0)
+ {
+ invalidated_nodes_counter = gdk_profiler_define_int_counter ("invalidated-nodes", "CSS Node
Invalidations");
+ created_styles_counter = gdk_profiler_define_int_counter ("created-styles", "CSS Style Creations");
+ }
+#endif
}
static void
@@ -1379,10 +1404,28 @@ void
gtk_css_node_validate (GtkCssNode *cssnode)
{
gint64 timestamp;
+#ifdef G_ENABLE_DEBUG
+ gint64 before = g_get_monotonic_time ();
+#endif
timestamp = gtk_css_node_get_timestamp (cssnode);
gtk_css_node_validate_internal (cssnode, timestamp);
+
+#ifdef G_ENABLE_DEBUG
+ if (cssnode->parent == NULL)
+ {
+ if (gdk_profiler_is_running ())
+ {
+ gint64 after = g_get_monotonic_time ();
+ gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "style", "");
+ gdk_profiler_set_int_counter (invalidated_nodes_counter, after * 1000, invalidated_nodes);
+ gdk_profiler_set_int_counter (created_styles_counter, after * 1000, created_styles);
+ invalidated_nodes = 0;
+ created_styles = 0;
+ }
+ }
+#endif
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]