From 5608a54708c3ab1665840c24bdfcb9c2b38fa78b Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 22 Apr 2010 17:52:13 +0100 Subject: [PATCH] profile: Fix the report generation Timers and counters might not exist, so make every section of the profile report depend on the object that it is querying. This fixes the profile report generation that was broken by commit 8146d8d08deafd6cf86238a4a8c2fa6149e5c691. --- clutter/clutter-profile.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/clutter/clutter-profile.c b/clutter/clutter-profile.c index aa8b715..baffaec 100644 --- a/clutter/clutter-profile.c +++ b/clutter/clutter-profile.c @@ -65,28 +65,28 @@ print_report (UProfReport *report, UProfContext *context) * initialized, so we don't have to care here. */ mainloop_timer = uprof_context_get_timer_result (context, "Mainloop"); - if (!mainloop_timer) - return; stage_paint_timer = uprof_context_get_timer_result (context, "Redrawing"); - if (!stage_paint_timer) - return; do_pick_timer = uprof_context_get_timer_result (context, "Do pick"); - if (!do_pick_timer) - return; - g_print ("\n"); + if (stage_paint_timer) + { + g_print ("\n"); - state.n_frames = uprof_timer_result_get_start_count (stage_paint_timer); - g_print ("Frame count = %lu\n", state.n_frames); + state.n_frames = uprof_timer_result_get_start_count (stage_paint_timer); + g_print ("Frame count = %lu\n", state.n_frames); - fps = (float)state.n_frames / (uprof_timer_result_get_total_msecs (mainloop_timer) + fps = (float) state.n_frames + / (uprof_timer_result_get_total_msecs (mainloop_timer) / 1000.0); - g_print ("Average fps = %5.2f\n", fps); + g_print ("Average fps = %5.2f\n", fps); + } if (do_pick_timer) { int n_picks = uprof_timer_result_get_start_count (do_pick_timer); + g_print ("\n"); + g_print ("Pick Stats:\n"); g_print ("Pick count = %d\n", n_picks); g_print ("Average picks per frame = %3.2f\n", @@ -94,10 +94,14 @@ print_report (UProfReport *report, UProfContext *context) g_print ("Average Msecs per pick = %3.2f\n", (float)uprof_timer_result_get_total_msecs (do_pick_timer) / (float)n_picks); - - g_print ("\n"); } + root_timers = uprof_context_get_root_timer_results (context); + if (!root_timers) + return; + + g_print ("\n"); + /* XXX: UProfs default reporting code now supports dynamic sizing for the Name * column, the only thing it's missing is support for adding custom columns but * when that's added we should switch away from manual report generation. */ @@ -111,7 +115,6 @@ print_report (UProfReport *report, UProfContext *context) g_print ("\n"); g_print ("Timers:\n"); - root_timers = uprof_context_get_root_timer_results (context); for (l = root_timers; l != NULL; l = l->next) uprof_timer_result_print_and_children ((UProfTimerResult *)l->data, print_timer_fields, -- 2.7.4