From b879397bdab0ea5b951ad8f79c4260bab5ad87c5 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 27 Jan 2012 08:53:44 +0100 Subject: [PATCH] [Profiler] Optimize time panel IS --- .../Resources/views/Collector/time.html.twig | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig index f14523881f..9515272f7b 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig @@ -93,6 +93,7 @@ var text, ms, xc, + mainEvents, colors = {{ colors|json_encode|raw }}, space = 10.5, ratio = (width - space * 2) / max, @@ -102,24 +103,17 @@ canvas = document.getElementById('timeline_' + request.id), ctx = canvas.getContext("2d"); - request.events.forEach(function(event) { - if (event.totaltime >= threshold) { - height += 38; - } + request.events = request.events.filter(function(event) { + return event.totaltime >= threshold; }); + height += 38 * request.events.length; canvas.width = width; ctx.textBaseline = "middle"; ctx.lineWidth = 0; request.events.forEach(function(event) { - - if (event.totaltime < threshold) { - return; - } - event.periods.forEach(function(period) { - if ('section.child' === event.name) { ctx.fillStyle = colors.child_sections; ctx.fillRect(x + period.begin * ratio, 0, (period.end - period.begin) * ratio, height); @@ -137,11 +131,11 @@ }); }); - request.events.forEach(function(event) { + mainEvents = request.events.filter(function(event) { + return 'section.child' !== event.name; + }); - if (event.totaltime < threshold || 'section.child' === event.name) { - return; - } + mainEvents.forEach(function(event) { h += 8; @@ -204,11 +198,7 @@ h = space; - request.events.forEach(function(event) { - - if (event.totaltime < threshold || 'section.child' === event.name) { - return; - } + mainEvents.forEach(function(event) { ctx.fillStyle = "#444"; ctx.font = "12px sans-serif";