clutter_uprof_destructor (void) { if (!(clutter_profile_flags & CLUTTER_PROFILE_DISABLE_REPORT)) { UProfReport *report = uprof_report_new ("Clutter report"); uprof_report_add_context (report, _clutter_uprof_context); uprof_report_add_context_callback (report, print_report); uprof_report_print (report); uprof_report_unref (report); } uprof_context_unref (_clutter_uprof_context); }
int main (int argc, char **argv) { UProfReport *report; UProfContext *context; int i; uprof_init (&argc, &argv); context = uprof_context_new ("Test"); for (i = 0; i < 4; i ++) { struct timespec delay; if (i == 1) { DBG_PRINTF ("suspending context\n"); uprof_context_suspend (context); } UPROF_COUNTER_INC (context, loop_counter); UPROF_TIMER_START (context, loop_timer); DBG_PRINTF (" <delay: 1 sec>\n"); delay.tv_sec = 1; delay.tv_nsec = 0; nanosleep (&delay, NULL); UPROF_TIMER_STOP (context, loop_timer); DBG_PRINTF ("stop simple timer (rdtsc = %" G_GUINT64_FORMAT ")\n", uprof_get_system_counter ()); if (i == 2) { DBG_PRINTF ("resuming context\n"); uprof_context_resume (context); } } DBG_PRINTF ("Expected result = 2 seconds accounted for and count == 2:\n"); report = uprof_report_new ("Suspend report"); uprof_report_add_context (report, context); uprof_report_print (report); uprof_report_unref (report); uprof_context_unref (context); return 0; }
void _clutter_uprof_init (void) { UProfContext *cogl_context; _clutter_uprof_context = uprof_context_new ("Clutter"); uprof_context_link (_clutter_uprof_context, uprof_get_mainloop_context ()); g_atexit (print_exit_report); cogl_context = uprof_find_context ("Cogl"); if (cogl_context) uprof_context_link (_clutter_uprof_context, cogl_context); /* We make the report object up-front so we can use uprof-tool * to fetch reports at runtime via dbus... */ clutter_uprof_report = uprof_report_new ("Clutter report"); uprof_report_add_context (clutter_uprof_report, _clutter_uprof_context); uprof_report_set_init_fini_callbacks (clutter_uprof_report, _clutter_uprof_report_prepare, _clutter_uprof_report_done, NULL); }
int main (int argc, char **argv) { UProfContext *context; UProfReport *report; int i; uprof_init (&argc, &argv); context = uprof_context_new ("Simple context"); DBG_PRINTF ("start full timer (rdtsc = %" G_GUINT64_FORMAT ")\n", uprof_get_system_counter ()); UPROF_TIMER_START (context, full_timer); for (i = 0; i < 2; i ++) { struct timespec delay; UPROF_COUNTER_INC (context, loop0_counter); DBG_PRINTF ("start simple timer (rdtsc = %" G_GUINT64_FORMAT ")\n", uprof_get_system_counter ()); UPROF_TIMER_START (context, loop0_timer); DBG_PRINTF (" <delay: 1/2 sec>\n"); delay.tv_sec = 0; delay.tv_nsec = 1000000000/2; nanosleep (&delay, NULL); UPROF_TIMER_START (context, loop0_sub_timer); DBG_PRINTF (" <timing sub delay: 1/4 sec>\n"); delay.tv_sec = 0; delay.tv_nsec = 1000000000/4; nanosleep (&delay, NULL); UPROF_TIMER_STOP (context, loop0_sub_timer); UPROF_TIMER_STOP (context, loop0_timer); DBG_PRINTF ("stop simple timer (rdtsc = %" G_GUINT64_FORMAT ")\n", uprof_get_system_counter ()); } for (i = 0; i < 4; i ++) { struct timespec delay; UPROF_COUNTER_INC (context, loop1_counter); DBG_PRINTF ("start simple timer (rdtsc = %" G_GUINT64_FORMAT ")\n", uprof_get_system_counter ()); UPROF_TIMER_START (context, loop1_timer); DBG_PRINTF (" <delay: 1/4 sec>\n"); delay.tv_sec = 0; delay.tv_nsec = 1000000000/4; nanosleep (&delay, NULL); UPROF_TIMER_START (context, loop1_sub_timer); DBG_PRINTF (" <timing sub delay: 1/2 sec>\n"); delay.tv_sec = 0; delay.tv_nsec = 1000000000/2; nanosleep (&delay, NULL); UPROF_TIMER_STOP (context, loop1_sub_timer); UPROF_TIMER_STOP (context, loop1_timer); DBG_PRINTF ("stop simple timer (rdtsc = %" G_GUINT64_FORMAT ")\n", uprof_get_system_counter ()); } DBG_PRINTF ("stop full timer (rdtsc = %" G_GUINT64_FORMAT ")\n", uprof_get_system_counter ()); UPROF_TIMER_STOP (context, full_timer); report = uprof_report_new ("Simple report"); uprof_report_add_statistic (report, "Special thingy", "This is a particularly interesting thingy"); uprof_report_add_statistic_attribute (report, "Special thingy", "Thingy A value", "Thingy A\nvalue", "The real A value of thingys", UPROF_ATTRIBUTE_TYPE_WORD, a_values_cb, NULL); uprof_report_add_statistic_attribute (report, "Special thingy", "Thingy B value", "Thingy B\nvalue", "The real B value of thingys", UPROF_ATTRIBUTE_TYPE_WORD, b_values_cb, NULL); uprof_report_add_statistic (report, "Special dobble", "This is a particularly interesting dobble"); uprof_report_add_statistic_attribute (report, "Special dobble", "Dobble value", "Dobble\nvalue", "The real value of dobbles", UPROF_ATTRIBUTE_TYPE_FLOAT, dobbles_cb, NULL); uprof_report_add_timers_attribute (report, "Time in seconds", "Time in\nseconds", "The time elapsed in seconds", UPROF_ATTRIBUTE_TYPE_INT, seconds_column_cb, NULL); uprof_report_add_counters_attribute (report, "Double count", "Double\ncount", "The count doubled", UPROF_ATTRIBUTE_TYPE_INT, double_count_cb, NULL); uprof_report_add_counters_attribute (report, "Tripple count", "Tripple\ncount", "The count trippled", UPROF_ATTRIBUTE_TYPE_INT, tripple_count_cb, NULL); uprof_report_add_context (report, context); uprof_report_print (report); uprof_report_unref (report); uprof_context_unref (context); return 0; }