[cogl/cogl-1.12] profile: Print warning if "Mainloop" timer missing
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/cogl-1.12] profile: Print warning if "Mainloop" timer missing
- Date: Mon, 3 Sep 2012 18:19:38 +0000 (UTC)
commit ac72d0685c3b0f5a8c0e79a75189392c841972ad
Author: Robert Bragg <robert linux intel com>
Date: Mon Aug 27 19:54:37 2012 +0100
profile: Print warning if "Mainloop" timer missing
As a helpful aid Cogl will now print a warning if no "Mainloop" UProf
timer was setup by the application that explains that either Clutter
should be built with --enable-profile or if Clutter isn't being used
then it shows how it can create its own Mainloop timer.
Reviewed-by: Neil Roberts <neil linux intel com>
(cherry picked from commit 3d052dbca86bf36f30b2d60ff59b967d14665436)
cogl/cogl-profile.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 43 insertions(+), 1 deletions(-)
---
diff --git a/cogl/cogl-profile.c b/cogl/cogl-profile.c
index f552b63..042fb78 100644
--- a/cogl/cogl-profile.c
+++ b/cogl/cogl-profile.c
@@ -35,7 +35,48 @@ print_exit_report (void)
{
if (getenv ("COGL_PROFILE_OUTPUT_REPORT"))
{
- UProfReport *report = uprof_report_new ("Cogl report");
+ UProfContext *mainloop_context;
+ UProfTimerResult *mainloop_timer;
+ UProfReport *report;
+
+ /* NB: uprof provides a shared context for mainloop statistics
+ * which needs to be setup by the application which controls the
+ * mainloop.
+ *
+ * If no "Mainloop" timer has been setup then we print a warning
+ * since we can't provide a meaningful Cogl report without one.
+ */
+ mainloop_context = uprof_get_mainloop_context ();
+ mainloop_timer = uprof_context_get_timer_result (mainloop_context,
+ "Mainloop");
+ /* just bail out if the mainloop timer wasn't hit */
+ if (!mainloop_timer)
+ {
+ g_warning ("\n\n"
+ "No UProf \"Mainloop\" timer was setup by the "
+ "application therefore we\ncan't provide a meaningful "
+ "profile report.\n"
+ "\n"
+ "This should be done automatically if you are using Clutter "
+ "(if\nbuilt with --enable-profile)\n"
+ "\n"
+ "If you aren't using Clutter then you can declare a "
+ "\"Mainloop\" UProf\ntimer in your application like this:\n\n"
+ " UPROF_STATIC_TIMER (mainloop_timer, \n"
+ " NULL,\n"
+ " \"Mainloop\",\n"
+ " \"Time in glib mainloop\",\n"
+ " 0);\n"
+ "\n"
+ "And start/stop it around your mainloop like this:\n"
+ "\n"
+ " UPROF_TIMER_START (uprof_get_mainloop_context (), mainloop_timer);\n"
+ " g_main_loop_run (loop);\n"
+ " UPROF_TIMER_STOP (uprof_get_mainloop_context (), mainloop_timer);\n");
+ return;
+ }
+
+ report = uprof_report_new ("Cogl report");
uprof_report_add_context (report, _cogl_uprof_context);
uprof_report_print (report);
uprof_report_unref (report);
@@ -47,6 +88,7 @@ void
_cogl_uprof_init (void)
{
_cogl_uprof_context = uprof_context_new ("Cogl");
+ uprof_context_link (_cogl_uprof_context, uprof_get_mainloop_context ());
#define OPT(MASK_NAME, GROUP, NAME, NAME_FORMATTED, DESCRIPTION) \
G_STMT_START { \
int shift = COGL_DEBUG_ ## MASK_NAME; \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]