[gtk/matthiasc/css-matching-4: 2/2] wip: quick per-frame css node stats
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/css-matching-4: 2/2] wip: quick per-frame css node stats
- Date: Mon, 20 Jan 2020 22:50:01 +0000 (UTC)
commit 468387c88c3431192127d484c9e68b0092361574
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jan 20 16:19:09 2020 -0500
wip: quick per-frame css node stats
Just print out the time that a toplevel css node takes
to validate, as well as the number of invalidated nodes,
created and cached styles.
gtk/gtkcssnode.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 4fe350d5ff..fdb5fb1f9c 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -122,6 +122,13 @@ gtk_css_node_get_style_provider_or_null (GtkCssNode *cssnode)
return GTK_CSS_NODE_GET_CLASS (cssnode)->get_style_provider (cssnode);
}
+#define GTK_CSS_NODE_ACCOUNTING
+#ifdef GTK_CSS_NODE_ACCOUNTING
+static int invalidated_nodes;
+static int created_styles;
+static int cached_styles;
+#endif
+
static void
gtk_css_node_set_invalid (GtkCssNode *node,
gboolean invalid)
@@ -131,6 +138,11 @@ gtk_css_node_set_invalid (GtkCssNode *node,
node->invalid = invalid;
+#ifdef GTK_CSS_NODE_ACCOUNTING
+ if (invalid)
+ invalidated_nodes++;
+#endif
+
if (node->visible)
{
if (node->parent)
@@ -367,7 +379,16 @@ gtk_css_node_create_style (GtkCssNode *cssnode,
style = lookup_in_global_parent_cache (cssnode, decl);
if (style)
- return g_object_ref (style);
+ {
+#ifdef GTK_CSS_NODE_ACCOUNTING
+ cached_styles++;
+#endif
+ return g_object_ref (style);
+ }
+
+#ifdef GTK_CSS_NODE_ACCOUNTING
+ created_styles++;
+#endif
parent = cssnode->parent ? cssnode->parent->style : NULL;
@@ -1379,10 +1400,27 @@ void
gtk_css_node_validate (GtkCssNode *cssnode)
{
gint64 timestamp;
+#ifdef GTK_CSS_NODE_ACCOUNTING
+ gint64 before = g_get_monotonic_time ();
+#endif
timestamp = gtk_css_node_get_timestamp (cssnode);
gtk_css_node_validate_internal (cssnode, timestamp);
+
+#ifdef GTK_CSS_NODE_ACCOUNTING
+ if (cssnode->parent == NULL)
+ {
+ g_print ("%g ms, nodes invalidated %d, styles created %d, cached %d\n",
+ ((double)(g_get_monotonic_time () - before)) / G_TIME_SPAN_MILLISECOND,
+ invalidated_nodes, created_styles, cached_styles);
+ invalidated_nodes = 0;
+ created_styles = 0;
+ cached_styles = 0;
+ if (g_getenv ("GTK_CSS_DEBUG_EXIT_AFTER_VALIDATE"))
+ exit (0);
+ }
+#endif
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]