profiling: Parse --clutter-profile and CLUTTER_PROFILE= options
As we have for debugging, this adds the ability to control profiling flags either via the command line or an environment variable. The first option added is CLUTTER_PROFILE=disable-report This also changes the reporting to be opt-out so you don't need to export CLUTTER_PROFILE_OUTPUT_REPORT=1 to see a report but you can use CLUTTER_PROFILE=disable-report to disable it if desired.
This commit is contained in:
parent
0057755854
commit
9cb530d42e
@ -137,6 +137,7 @@ static guint clutter_main_loop_level = 0;
|
||||
static GSList *main_loops = NULL;
|
||||
|
||||
guint clutter_debug_flags = 0; /* global clutter debug flag */
|
||||
guint clutter_profile_flags = 0; /* global clutter profile flag */
|
||||
|
||||
const guint clutter_major_version = CLUTTER_MAJOR_VERSION;
|
||||
const guint clutter_minor_version = CLUTTER_MINOR_VERSION;
|
||||
@ -165,6 +166,12 @@ static const GDebugKey clutter_debug_keys[] = {
|
||||
};
|
||||
#endif /* CLUTTER_ENABLE_DEBUG */
|
||||
|
||||
#ifdef CLUTTER_ENABLE_PROFILE
|
||||
static const GDebugKey clutter_profile_keys[] = {
|
||||
{"disable-report", CLUTTER_PROFILE_DISABLE_REPORT }
|
||||
};
|
||||
#endif /* CLUTTER_ENABLE_DEBUG */
|
||||
|
||||
/**
|
||||
* clutter_get_show_fps:
|
||||
*
|
||||
@ -1423,6 +1430,32 @@ clutter_arg_no_debug_cb (const char *key,
|
||||
}
|
||||
#endif /* CLUTTER_ENABLE_DEBUG */
|
||||
|
||||
#ifdef CLUTTER_ENABLE_PROFILE
|
||||
static gboolean
|
||||
clutter_arg_profile_cb (const char *key,
|
||||
const char *value,
|
||||
gpointer user_data)
|
||||
{
|
||||
clutter_profile_flags |=
|
||||
g_parse_debug_string (value,
|
||||
clutter_profile_keys,
|
||||
G_N_ELEMENTS (clutter_profile_keys));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_arg_no_profile_cb (const char *key,
|
||||
const char *value,
|
||||
gpointer user_data)
|
||||
{
|
||||
clutter_profile_flags &=
|
||||
~g_parse_debug_string (value,
|
||||
clutter_profile_keys,
|
||||
G_N_ELEMENTS (clutter_profile_keys));
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* CLUTTER_ENABLE_PROFILE */
|
||||
|
||||
GQuark
|
||||
clutter_init_error_quark (void)
|
||||
{
|
||||
@ -1557,6 +1590,12 @@ static GOptionEntry clutter_args[] = {
|
||||
{ "clutter-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, clutter_arg_no_debug_cb,
|
||||
N_("Clutter debugging flags to unset"), "FLAGS" },
|
||||
#endif /* CLUTTER_ENABLE_DEBUG */
|
||||
#ifdef CLUTTER_ENABLE_PROFILE
|
||||
{ "clutter-profile", 0, 0, G_OPTION_ARG_CALLBACK, clutter_arg_profile_cb,
|
||||
N_("Clutter profiling flags to set"), "FLAGS" },
|
||||
{ "clutter-no-profile", 0, 0, G_OPTION_ARG_CALLBACK, clutter_arg_no_profile_cb,
|
||||
N_("Clutter profiling flags to unset"), "FLAGS" },
|
||||
#endif /* CLUTTER_ENABLE_PROFILE */
|
||||
{ NULL, },
|
||||
};
|
||||
|
||||
@ -1600,6 +1639,18 @@ pre_parse_hook (GOptionContext *context,
|
||||
}
|
||||
#endif /* CLUTTER_ENABLE_DEBUG */
|
||||
|
||||
#ifdef CLUTTER_ENABLE_PROFILE
|
||||
env_string = g_getenv ("CLUTTER_PROFILE");
|
||||
if (env_string != NULL)
|
||||
{
|
||||
clutter_profile_flags =
|
||||
g_parse_debug_string (env_string,
|
||||
clutter_profile_keys,
|
||||
G_N_ELEMENTS (clutter_profile_keys));
|
||||
env_string = NULL;
|
||||
}
|
||||
#endif /* CLUTTER_ENABLE_PROFILE */
|
||||
|
||||
env_string = g_getenv ("CLUTTER_SHOW_FPS");
|
||||
if (env_string)
|
||||
clutter_show_fps = TRUE;
|
||||
|
@ -155,7 +155,7 @@ print_timers (UProfContext *context)
|
||||
static void __attribute__ ((destructor))
|
||||
clutter_uprof_destructor (void)
|
||||
{
|
||||
if (getenv ("CLUTTER_PROFILE_OUTPUT_REPORT"))
|
||||
if (!(clutter_profile_flags & CLUTTER_PROFILE_DISABLE_REPORT))
|
||||
{
|
||||
UProfReport *report = uprof_report_new ("Clutter report");
|
||||
uprof_report_add_context (report, _clutter_uprof_context);
|
||||
|
@ -26,8 +26,14 @@
|
||||
#ifndef _CLUTTER_PROFILE_H_
|
||||
#define _CLUTTER_PROFILE_H_
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef enum {
|
||||
CLUTTER_PROFILE_DISABLE_REPORT = 1 << 1
|
||||
} ClutterProfileFlag;
|
||||
|
||||
#ifdef CLUTTER_ENABLE_PROFILE
|
||||
|
||||
#include <uprof.h>
|
||||
@ -52,6 +58,8 @@ extern UProfContext *_clutter_uprof_context;
|
||||
|
||||
#endif /* CLUTTER_ENABLE_PROFILE */
|
||||
|
||||
extern guint clutter_profile_flags;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _CLUTTER_PROFILE_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user