mutter/clutter/cogl/cogl/cogl-profile.c

81 lines
1.9 KiB
C
Raw Normal View History

#ifdef COGL_ENABLE_PROFILE
#include "cogl-profile.h"
profile: Update to uprof-0.3 dep for --enable-profile When building with --enable-profile we now depend on the uprof-0.3 developer release which brings a few improvements: » It lets us "fix" how we initialize uprof so that instead of using a shared object constructor/destructor (which was a hack used when first adding uprof support to Clutter) we can now initialize as part of clutter's normal initialization code. As a side note though, I found that the way Clutter initializes has some quite serious problems whenever it involves GOptionGroups. It is not able to guarantee the initialization of dependencies like uprof and Cogl. For this reason we still use the contructor/destructor approach to initialize uprof in Cogl. » uprof-0.3 provides a better API for adding custom columns when reporting timer and counter statistics which lets us remove quite a lot of manual report generation code in clutter-profile.c. » uprof-0.3 provides a shared context for tracking mainloop timer statistics. This means any mainloop based library following the same "Mainloop" timer naming convention can use the shared context and no matter who ends up owning the final mainloop the statistics will always be in the same place. This allows profiling of Clutter with an external mainloop such as with the Mutter compositor. » uprof-0.3 can export statistics over dbus and comes with an ncurses based ui to vizualize timer and counter stats live. The latest version of uprof can be cloned from: git://github.com/rib/UProf.git
2010-06-21 10:36:46 -04:00
#include "cogl-debug.h"
#include <stdlib.h>
UProfContext *_cogl_uprof_context;
profile: Update to uprof-0.3 dep for --enable-profile When building with --enable-profile we now depend on the uprof-0.3 developer release which brings a few improvements: » It lets us "fix" how we initialize uprof so that instead of using a shared object constructor/destructor (which was a hack used when first adding uprof support to Clutter) we can now initialize as part of clutter's normal initialization code. As a side note though, I found that the way Clutter initializes has some quite serious problems whenever it involves GOptionGroups. It is not able to guarantee the initialization of dependencies like uprof and Cogl. For this reason we still use the contructor/destructor approach to initialize uprof in Cogl. » uprof-0.3 provides a better API for adding custom columns when reporting timer and counter statistics which lets us remove quite a lot of manual report generation code in clutter-profile.c. » uprof-0.3 provides a shared context for tracking mainloop timer statistics. This means any mainloop based library following the same "Mainloop" timer naming convention can use the shared context and no matter who ends up owning the final mainloop the statistics will always be in the same place. This allows profiling of Clutter with an external mainloop such as with the Mutter compositor. » uprof-0.3 can export statistics over dbus and comes with an ncurses based ui to vizualize timer and counter stats live. The latest version of uprof can be cloned from: git://github.com/rib/UProf.git
2010-06-21 10:36:46 -04:00
static gboolean
debug_option_getter (void *user_data)
{
unsigned int shift = GPOINTER_TO_UINT (user_data);
return (cogl_debug_flags & (1 << shift)) ? TRUE : FALSE;
}
static void
debug_option_setter (gboolean value, void *user_data)
{
unsigned int shift = GPOINTER_TO_UINT (user_data);
if (value)
cogl_debug_flags |= (1 << shift);
else
cogl_debug_flags &= ~(1 << shift);
}
static void
print_exit_report (void)
{
if (getenv ("COGL_PROFILE_OUTPUT_REPORT"))
{
UProfReport *report = uprof_report_new ("Cogl report");
uprof_report_add_context (report, _cogl_uprof_context);
uprof_report_print (report);
uprof_report_unref (report);
}
uprof_context_unref (_cogl_uprof_context);
}
void
_cogl_uprof_init (void)
{
_cogl_uprof_context = uprof_context_new ("Cogl");
profile: Update to uprof-0.3 dep for --enable-profile When building with --enable-profile we now depend on the uprof-0.3 developer release which brings a few improvements: » It lets us "fix" how we initialize uprof so that instead of using a shared object constructor/destructor (which was a hack used when first adding uprof support to Clutter) we can now initialize as part of clutter's normal initialization code. As a side note though, I found that the way Clutter initializes has some quite serious problems whenever it involves GOptionGroups. It is not able to guarantee the initialization of dependencies like uprof and Cogl. For this reason we still use the contructor/destructor approach to initialize uprof in Cogl. » uprof-0.3 provides a better API for adding custom columns when reporting timer and counter statistics which lets us remove quite a lot of manual report generation code in clutter-profile.c. » uprof-0.3 provides a shared context for tracking mainloop timer statistics. This means any mainloop based library following the same "Mainloop" timer naming convention can use the shared context and no matter who ends up owning the final mainloop the statistics will always be in the same place. This allows profiling of Clutter with an external mainloop such as with the Mutter compositor. » uprof-0.3 can export statistics over dbus and comes with an ncurses based ui to vizualize timer and counter stats live. The latest version of uprof can be cloned from: git://github.com/rib/UProf.git
2010-06-21 10:36:46 -04:00
#define OPT(MASK_NAME, GROUP, NAME, NAME_FORMATTED, DESCRIPTION) \
G_STMT_START { \
int shift; \
for (shift = 0; (COGL_DEBUG_ ## MASK_NAME >> shift) != 1; shift++) \
; \
uprof_context_add_boolean_option (_cogl_uprof_context, \
GROUP, \
NAME, \
NAME_FORMATTED, \
DESCRIPTION, \
debug_option_getter, \
debug_option_setter, \
GUINT_TO_POINTER (shift)); \
} G_STMT_END;
#include "cogl-debug-options.h"
#undef OPT
g_atexit (print_exit_report);
}
profile: Update to uprof-0.3 dep for --enable-profile When building with --enable-profile we now depend on the uprof-0.3 developer release which brings a few improvements: » It lets us "fix" how we initialize uprof so that instead of using a shared object constructor/destructor (which was a hack used when first adding uprof support to Clutter) we can now initialize as part of clutter's normal initialization code. As a side note though, I found that the way Clutter initializes has some quite serious problems whenever it involves GOptionGroups. It is not able to guarantee the initialization of dependencies like uprof and Cogl. For this reason we still use the contructor/destructor approach to initialize uprof in Cogl. » uprof-0.3 provides a better API for adding custom columns when reporting timer and counter statistics which lets us remove quite a lot of manual report generation code in clutter-profile.c. » uprof-0.3 provides a shared context for tracking mainloop timer statistics. This means any mainloop based library following the same "Mainloop" timer naming convention can use the shared context and no matter who ends up owning the final mainloop the statistics will always be in the same place. This allows profiling of Clutter with an external mainloop such as with the Mutter compositor. » uprof-0.3 can export statistics over dbus and comes with an ncurses based ui to vizualize timer and counter stats live. The latest version of uprof can be cloned from: git://github.com/rib/UProf.git
2010-06-21 10:36:46 -04:00
void
_cogl_profile_trace_message (const char *format, ...)
{
va_list ap;
va_start (ap, format);
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, ap);
va_end (ap);
if (_cogl_uprof_context)
uprof_context_vtrace_message (_cogl_uprof_context, format, ap);
}
#endif