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
This commit is contained in:
@ -904,13 +904,13 @@ timed_poll (GPollFD *ufds,
|
||||
gint ret;
|
||||
CLUTTER_STATIC_TIMER (poll_timer,
|
||||
"Mainloop", /* parent */
|
||||
"poll (idle)",
|
||||
"Mainloop Idle",
|
||||
"The time spent idle in poll()",
|
||||
0 /* no application private data */);
|
||||
|
||||
CLUTTER_TIMER_START (_clutter_uprof_context, poll_timer);
|
||||
CLUTTER_TIMER_START (uprof_get_mainloop_context (), poll_timer);
|
||||
ret = prev_poll (ufds, nfsd, timeout_);
|
||||
CLUTTER_TIMER_STOP (_clutter_uprof_context, poll_timer);
|
||||
CLUTTER_TIMER_STOP (uprof_get_mainloop_context (), poll_timer);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
@ -931,7 +931,7 @@ clutter_main (void)
|
||||
0 /* no application private data */);
|
||||
|
||||
if (clutter_main_loop_level == 0)
|
||||
CLUTTER_TIMER_START (_clutter_uprof_context, mainloop_timer);
|
||||
CLUTTER_TIMER_START (uprof_get_mainloop_context (), mainloop_timer);
|
||||
|
||||
/* Make sure there is a context */
|
||||
CLUTTER_CONTEXT ();
|
||||
@ -981,7 +981,7 @@ clutter_main (void)
|
||||
CLUTTER_MARK ();
|
||||
|
||||
if (clutter_main_loop_level == 0)
|
||||
CLUTTER_TIMER_STOP (_clutter_uprof_context, mainloop_timer);
|
||||
CLUTTER_TIMER_STOP (uprof_get_mainloop_context (), mainloop_timer);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1621,12 +1621,19 @@ clutter_init_real (GError **error)
|
||||
return CLUTTER_INIT_ERROR_BACKEND;
|
||||
|
||||
#ifdef CLUTTER_ENABLE_PROFILE
|
||||
{
|
||||
UProfContext *cogl_context;
|
||||
cogl_context = uprof_find_context ("Cogl");
|
||||
if (cogl_context)
|
||||
uprof_context_link (_clutter_uprof_context, cogl_context);
|
||||
}
|
||||
/* We need to be absolutely sure that uprof has been initialized
|
||||
* before calling _clutter_uprof_init. uprof_init (NULL, NULL)
|
||||
* will be a NOP if it has been initialized but it will also
|
||||
* mean subsequent parsing of the UProf GOptionGroup will have no
|
||||
* affect.
|
||||
*
|
||||
* Sadly GOptionGroup based library initialization is extremly
|
||||
* fragile by design because GOptionGroups have no notion of
|
||||
* dependencies and our post_parse_hook may be called before
|
||||
* the cogl or uprof groups get parsed.
|
||||
*/
|
||||
uprof_init (NULL, NULL);
|
||||
_clutter_uprof_init ();
|
||||
|
||||
if (clutter_profile_flags & CLUTTER_PROFILE_PICKING_ONLY)
|
||||
_clutter_profile_suspend ();
|
||||
@ -1995,6 +2002,14 @@ clutter_init_with_args (int *argc,
|
||||
group = cogl_get_option_group ();
|
||||
g_option_context_add_group (context, group);
|
||||
|
||||
/* Note: That due to the implementation details of glib's goption
|
||||
* parsing; cogl and uprof will not actually have there arguments
|
||||
* parsed before the post_parse_hook is called! */
|
||||
#ifdef CLUTTER_ENABLE_PROFILE
|
||||
group = uprof_get_option_group ();
|
||||
g_option_context_add_group (context, group);
|
||||
#endif
|
||||
|
||||
if (entries)
|
||||
g_option_context_add_main_entries (context, entries, translation_domain);
|
||||
|
||||
@ -2027,6 +2042,9 @@ clutter_parse_args (int *argc,
|
||||
{
|
||||
GOptionContext *option_context;
|
||||
GOptionGroup *clutter_group, *cogl_group;
|
||||
#ifdef CLUTTER_ENABLE_PROFILE
|
||||
GOptionGroup *uprof_group;
|
||||
#endif
|
||||
GError *error = NULL;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
@ -2045,6 +2063,11 @@ clutter_parse_args (int *argc,
|
||||
cogl_group = cogl_get_option_group ();
|
||||
g_option_context_add_group (option_context, cogl_group);
|
||||
|
||||
#ifdef CLUTTER_ENABLE_PROFILE
|
||||
uprof_group = uprof_get_option_group ();
|
||||
g_option_context_add_group (option_context, uprof_group);
|
||||
#endif
|
||||
|
||||
if (!g_option_context_parse (option_context, argc, argv, &error))
|
||||
{
|
||||
if (error)
|
||||
|
Reference in New Issue
Block a user