diff options
author | Robert Bragg <robert@linux.intel.com> | 2009-07-03 16:22:35 +0100 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2010-01-08 20:19:50 +0000 |
commit | fbad0a75b684cebbff874ba689810c2ff763b6e8 (patch) | |
tree | f7abac2b253b5630199c6bd389af375d86792792 /cogl/cogl-profile.c | |
parent | e9c4a0467b8f65531e5f8670332f3c7af07359ee (diff) |
profiling: Adds initial UProf accounting to Cogl
This adds gives Cogl a dedicated UProf context which will be linked together
with Clutter's context during clutter_init_real().
Initial timers cover _cogl_journal_flush and _cogl_journal_log_quad
You can explicitly ask for a report of Cogl statistics by exporting
COGL_PROFILE_OUTPUT_REPORT=1 but since the context is linked with Clutter's
the statisitcs will also be shown in the automatic Clutter reports.
Diffstat (limited to 'cogl/cogl-profile.c')
-rw-r--r-- | cogl/cogl-profile.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cogl/cogl-profile.c b/cogl/cogl-profile.c new file mode 100644 index 00000000..e17acda3 --- /dev/null +++ b/cogl/cogl-profile.c @@ -0,0 +1,30 @@ + +#ifdef COGL_ENABLE_PROFILE + +#include "cogl-profile.h" + +#include <stdlib.h> + +UProfContext *_cogl_uprof_context; + + +static void __attribute__ ((constructor)) +cogl_uprof_constructor (void) +{ + _cogl_uprof_context = uprof_context_new ("Cogl"); +} + +static void __attribute__ ((destructor)) +cogl_uprof_destructor (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); +} + +#endif |