[gnome-builder] support: Log the counters



commit 557c34043611f3fd8fe273dbf5c0e34b5d76a9d1
Author: Garrett Regier <garrettregier gmail com>
Date:   Tue May 12 13:45:44 2015 -0700

    support: Log the counters

 src/support/gb-support.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/support/gb-support.c b/src/support/gb-support.c
index 42d0da8..2dfa785 100644
--- a/src/support/gb-support.c
+++ b/src/support/gb-support.c
@@ -19,9 +19,29 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
+#include "egg-counter.h"
 #include "gb-application.h"
 #include "gb-support.h"
 
+static gchar *
+str_to_key (const gchar *str)
+{
+  return g_strdelimit (g_strdup (str), " ", '_');
+}
+
+static void
+counter_arena_foreach_cb (EggCounter *counter,
+                          gpointer    user_data)
+{
+  GString *str = (GString *)user_data;
+  g_autofree gchar *category = str_to_key (counter->category);
+  g_autofree gchar *name = str_to_key (counter->name);
+
+  g_string_append_printf (str,
+                          "%s.%s = %"G_GINT64_FORMAT"\n",
+                          category, name, egg_counter_get (counter));
+}
+
 gchar *
 gb_get_support_log (void)
 {
@@ -127,6 +147,14 @@ gb_get_support_log (void)
       g_free (key);
     }
   g_strfreev (env);
+  g_string_append (str, "\n");
+
+  /*
+   * Log the counters.
+   */
+  g_string_append (str, "[runtime.counters]\n");
+  egg_counter_arena_foreach (egg_counter_arena_get_default (),
+                             counter_arena_foreach_cb, str);
 
   g_string_append (str, "\n\n");
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]