diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-01-19 09:04:29 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-01-20 20:07:59 -0500 |
commit | 2e74d1cbf49c6d4c4dda830bf7fd208f6914d0c0 (patch) | |
tree | 9af8cb4f8f9b2bbe6a43ea622c45c5dc19634411 | |
parent | f4e4e4030e99cb0ae505f60b9c192128f692d80a (diff) | |
download | gtk+-2e74d1cbf49c6d4c4dda830bf7fd208f6914d0c0.tar.gz |
selector stats
-rw-r--r-- | gtk/gtkcssselector.c | 20 | ||||
-rw-r--r-- | gtk/gtkwindow.c | 4 |
2 files changed, 23 insertions, 1 deletions
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c index aabffb3e3e..50414edac3 100644 --- a/gtk/gtkcssselector.c +++ b/gtk/gtkcssselector.c @@ -171,11 +171,29 @@ gtk_css_selector_tree_found_match (const GtkCssSelectorTree *tree, } } +static int match_count; +static int positive_match_count; + +void print_match_count (void); +void print_match_count (void) +{ + g_print ("%d selector matches (%d positive)\n", match_count, positive_match_count); + match_count = 0; + positive_match_count = 0; +} + static inline gboolean gtk_css_selector_match (const GtkCssSelector *selector, const GtkCssMatcher *matcher) { - return selector->class->match_one (selector, matcher); + gboolean result; + + result = selector->class->match_one (selector, matcher); + + match_count++; + positive_match_count += result; + + return result; } static inline gboolean diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index e390e6bca2..0ff22e59af 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -6008,11 +6008,15 @@ surface_size_changed (GtkWidget *widget, gtk_window_configure (GTK_WINDOW (widget), width, height); } +extern void print_match_count (void); + static gboolean surface_render (GdkSurface *surface, cairo_region_t *region, GtkWidget *widget) { + print_match_count (); + gtk_widget_render (widget, surface, region); return TRUE; } |