[Cogl] [PATCH] test-journal: Setup a UProf Mainloop timer

Robert Bragg robert at sixbynine.org
Tue Aug 28 08:51:22 PDT 2012


From: Robert Bragg <robert at linux.intel.com>

So that we can show a UProf profile when running test-journal the test
now declares a static "Mainloop" timer which it starts/stops around the
GLib mainloop it runs.
---
 tests/micro-perf/test-journal.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/tests/micro-perf/test-journal.c b/tests/micro-perf/test-journal.c
index 9cd9cba..42de7a5 100644
--- a/tests/micro-perf/test-journal.c
+++ b/tests/micro-perf/test-journal.c
@@ -2,6 +2,8 @@
 #include <cogl/cogl.h>
 #include <math.h>
 
+#include "cogl/cogl-profile.h"
+
 #define FRAMEBUFFER_WIDTH 800
 #define FRAMEBUFFER_HEIGHT 600
 
@@ -141,6 +143,11 @@ main (int argc, char **argv)
   CoglOnscreen *onscreen;
   GSource *cogl_source;
   GMainLoop *loop;
+  COGL_STATIC_TIMER (mainloop_timer,
+                      NULL, //no parent
+                      "Mainloop",
+                      "The time spent in the glib mainloop",
+                      0);  // no application private data
 
   data.ctx = cogl_context_new (NULL, NULL);
 
@@ -176,7 +183,9 @@ main (int argc, char **argv)
   g_timer_start (data.timer);
 
   loop = g_main_loop_new (NULL, TRUE);
+  COGL_TIMER_START (uprof_get_mainloop_context (), mainloop_timer);
   g_main_loop_run (loop);
+  COGL_TIMER_STOP (uprof_get_mainloop_context (), mainloop_timer);
 
   return 0;
 }
-- 
1.7.7.6



More information about the Cogl mailing list