profiling: Allow limiting statisics just to picking

This suspends and resumes all uprof timers and counters except while dealing
with picking, so as to give more focused statistics.

Be aware that there are still some issues with this profile option since
there are a few special case counters and timers that shouldn't be
suspended; noteably the frame counters are incorrect so the per frame stats
can't be trusted.
This commit is contained in:
Robert Bragg 2009-04-17 12:15:56 +01:00
parent 9cb530d42e
commit 0b6515a1d5
3 changed files with 58 additions and 2 deletions

View File

@ -168,6 +168,7 @@ static const GDebugKey clutter_debug_keys[] = {
#ifdef CLUTTER_ENABLE_PROFILE
static const GDebugKey clutter_profile_keys[] = {
{"picking-only", CLUTTER_PROFILE_PICKING_ONLY },
{"disable-report", CLUTTER_PROFILE_DISABLE_REPORT }
};
#endif /* CLUTTER_ENABLE_DEBUG */
@ -574,6 +575,11 @@ _clutter_do_pick (ClutterStage *stage,
if (clutter_debug_flags & CLUTTER_DEBUG_NOP_PICKING)
return CLUTTER_ACTOR (stage);
#ifdef CLUTTER_ENABLE_PROFILE
if (clutter_profile_flags & CLUTTER_PROFILE_PICKING_ONLY)
_clutter_profile_resume ();
#endif /* CLUTTER_ENABLE_PROFILE */
CLUTTER_COUNTER_INC (_clutter_uprof_context, do_pick_counter);
CLUTTER_TIMER_START (_clutter_uprof_context, pick_timer);
@ -636,15 +642,22 @@ _clutter_do_pick (ClutterStage *stage,
if (pixel[0] == 0xff && pixel[1] == 0xff && pixel[2] == 0xff)
{
CLUTTER_TIMER_STOP (_clutter_uprof_context, pick_timer);
return CLUTTER_ACTOR (stage);
actor = CLUTTER_ACTOR (stage);
goto result;
}
id = _clutter_pixel_to_id (pixel);
actor = clutter_get_actor_by_gid (id);
result:
CLUTTER_TIMER_STOP (_clutter_uprof_context, pick_timer);
#ifdef CLUTTER_ENABLE_PROFILE
if (clutter_profile_flags & CLUTTER_PROFILE_PICKING_ONLY)
_clutter_profile_suspend ();
#endif
return actor;
}
@ -1528,6 +1541,11 @@ clutter_init_real (GError **error)
/* - will call to backend and cogl */
_clutter_feature_init ();
#ifdef CLUTTER_ENABLE_PROFILE
if (clutter_profile_flags & CLUTTER_PROFILE_PICKING_ONLY)
_clutter_profile_suspend ();
#endif
/*
* Resolution requires display to be open, so can only be queried after
* the post_parse hooks run.

View File

@ -8,6 +8,9 @@
UProfContext *_clutter_uprof_context;
#define REPORT_COLUMN0_WIDTH 40
static gboolean searched_for_gl_uprof_context = FALSE;
static UProfContext *gl_uprof_context = NULL;
typedef struct _ClutterUProfReportState
{
gulong n_frames;
@ -166,5 +169,31 @@ clutter_uprof_destructor (void)
uprof_context_unref (_clutter_uprof_context);
}
void
_clutter_profile_suspend (void)
{
if (G_UNLIKELY (!searched_for_gl_uprof_context))
{
gl_uprof_context = uprof_find_context ("OpenGL");
searched_for_gl_uprof_context = TRUE;
}
if (gl_uprof_context)
uprof_context_suspend (gl_uprof_context);
/* NB: The Cogl context is linked to this so it will also be suspended... */
uprof_context_suspend (_clutter_uprof_context);
}
void
_clutter_profile_resume (void)
{
if (gl_uprof_context)
uprof_context_resume (gl_uprof_context);
/* NB: The Cogl context is linked to this so it will also be resumed... */
uprof_context_resume (_clutter_uprof_context);
}
#endif

View File

@ -31,6 +31,7 @@
G_BEGIN_DECLS
typedef enum {
CLUTTER_PROFILE_PICKING_ONLY = 1 << 0,
CLUTTER_PROFILE_DISABLE_REPORT = 1 << 1
} ClutterProfileFlag;
@ -47,6 +48,11 @@ extern UProfContext *_clutter_uprof_context;
#define CLUTTER_TIMER_START UPROF_TIMER_START
#define CLUTTER_TIMER_STOP UPROF_TIMER_STOP
void
_clutter_profile_suspend (void);
void
_clutter_profile_resume (void);
#else /* CLUTTER_ENABLE_PROFILE */
#define CLUTTER_STATIC_TIMER(A,B,C,D,E) extern void _clutter_dummy_decl (void)
@ -56,6 +62,9 @@ extern UProfContext *_clutter_uprof_context;
#define CLUTTER_TIMER_START(A,B) G_STMT_START{ (void)0; }G_STMT_END
#define CLUTTER_TIMER_STOP(A,B) G_STMT_START{ (void)0; }G_STMT_END
#define _clutter_profile_suspend() G_STMT_START {} G_STMT_END
#define _clutter_profile_resume() G_STMT_START {} G_STMT_END
#endif /* CLUTTER_ENABLE_PROFILE */
extern guint clutter_profile_flags;