From: Matthias Clasen Date: Fri, 10 Jan 2020 04:48:30 +0000 (-0500) Subject: dump css value stats X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~20^2~298 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=741e12012dcee880d72fd292b62c4d8d5b7dd276;p=gtk4.git dump css value stats --- diff --git a/gtk/gtkcssvalue.c b/gtk/gtkcssvalue.c index 3f965bdf0c..20d6b78e38 100644 --- a/gtk/gtkcssvalue.c +++ b/gtk/gtkcssvalue.c @@ -29,6 +29,54 @@ struct _GtkCssValue { G_DEFINE_BOXED_TYPE (GtkCssValue, _gtk_css_value, _gtk_css_value_ref, _gtk_css_value_unref) +static GHashTable *counters; + +static void +dump_value_counts (void) +{ + GHashTableIter iter; + gpointer key; + gpointer value; + + int sum1 = 0, sum2 = 0; + g_hash_table_iter_init (&iter, counters); + while (g_hash_table_iter_next (&iter, &key, &value)) + { + const char *class = key; + int *c = value; + if (c[0] != 1) + g_print ("%d %d %s\n", c[0], c[0] - c[1], class); + + sum1 += c[0]; + sum2 += c[0] - c[1]; + } + + g_print ("SUM: %d, %d\n", sum1, sum2); +} + +static void +count_value (const char *class, int delta) +{ + int *c; + + if (!counters) + { + counters = g_hash_table_new (g_str_hash, g_str_equal); + atexit (dump_value_counts); + } + c = g_hash_table_lookup (counters, class); + if (!c) + { + c = g_new0 (int, 2); + g_hash_table_insert (counters, (gpointer)class, c); + } + + if (delta == 1) + c[0]++; + else + c[1]++; +} + GtkCssValue * _gtk_css_value_alloc (const GtkCssValueClass *klass, gsize size) @@ -40,6 +88,8 @@ _gtk_css_value_alloc (const GtkCssValueClass *klass, value->class = klass; value->ref_count = 1; + count_value (klass->type_name, 1); + return value; } @@ -63,6 +113,8 @@ gtk_css_value_unref (GtkCssValue *value) if (value->ref_count > 0) return; + count_value (value->class->type_name, -1); + value->class->free (value); }