[Stopwatch] rename the section event to avoid collisions
This commit is contained in:
parent
eb540bef29
commit
acd1287d02
@ -266,7 +266,7 @@ class TraceableEventDispatcher extends ContainerAwareEventDispatcher implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
$events = $this->stopwatch->getSectionEvents($token);
|
$events = $this->stopwatch->getSectionEvents($token);
|
||||||
$origin = $events['section']->getOrigin();
|
$origin = $events['__section__']->getOrigin();
|
||||||
|
|
||||||
foreach ($this->stopwatch->getSectionEvents($token.'.terminate') as $name => $event) {
|
foreach ($this->stopwatch->getSectionEvents($token.'.terminate') as $name => $event) {
|
||||||
if (isset($events[$name])) {
|
if (isset($events[$name])) {
|
||||||
|
@ -64,14 +64,14 @@
|
|||||||
<h3>
|
<h3>
|
||||||
Main Request
|
Main Request
|
||||||
<small>
|
<small>
|
||||||
- {{ collector.events.section.totaltime }} ms
|
- {{ collector.events.__section__.totaltime }} ms
|
||||||
{% if profile.parent %}
|
{% if profile.parent %}
|
||||||
- <a href="{{ path('_profiler', { 'token': profile.parent.token }) }}?panel=time&threshold={{ threshold }}&width={{ width }}">parent</a>
|
- <a href="{{ path('_profiler', { 'token': profile.parent.token }) }}?panel=time&threshold={{ threshold }}&width={{ width }}">parent</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</small>
|
</small>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
{% set max = collector.events.section.endtime %}
|
{% set max = collector.events.__section__.endtime %}
|
||||||
|
|
||||||
{{ _self.display_timeline('timeline_' ~ token, collector.events, threshold, colors, width) }}
|
{{ _self.display_timeline('timeline_' ~ token, collector.events, threshold, colors, width) }}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@
|
|||||||
{% set events = child.getcollector('time').events %}
|
{% set events = child.getcollector('time').events %}
|
||||||
<h3>
|
<h3>
|
||||||
Sub-request "<a href="{{ path('_profiler', { 'token': child.token }) }}?panel=time&threshold={{ threshold }}&width={{ width }}">{{ child.getcollector('request').requestattributes.get('_controller') }}</a>"
|
Sub-request "<a href="{{ path('_profiler', { 'token': child.token }) }}?panel=time&threshold={{ threshold }}&width={{ width }}">{{ child.getcollector('request').requestattributes.get('_controller') }}</a>"
|
||||||
<small> - {{ events.section.totaltime }} ms</small>
|
<small> - {{ events.__section__.totaltime }} ms</small>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
{{ _self.display_timeline('timeline_' ~ child.token, events, threshold, colors, width) }}
|
{{ _self.display_timeline('timeline_' ~ child.token, events, threshold, colors, width) }}
|
||||||
@ -114,7 +114,7 @@
|
|||||||
|
|
||||||
request.events.forEach(function(event) {
|
request.events.forEach(function(event) {
|
||||||
event.periods.forEach(function(period) {
|
event.periods.forEach(function(period) {
|
||||||
if ('section.child' === event.name) {
|
if ('__section__.child' === event.name) {
|
||||||
ctx.fillStyle = colors.child_sections;
|
ctx.fillStyle = colors.child_sections;
|
||||||
ctx.fillRect(x + period.begin * ratio, 0, (period.end - period.begin) * ratio, height);
|
ctx.fillRect(x + period.begin * ratio, 0, (period.end - period.begin) * ratio, height);
|
||||||
} else if ('section' === event.category) {
|
} else if ('section' === event.category) {
|
||||||
@ -132,7 +132,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
mainEvents = request.events.filter(function(event) {
|
mainEvents = request.events.filter(function(event) {
|
||||||
return 'section.child' !== event.name;
|
return '__section__.child' !== event.name;
|
||||||
});
|
});
|
||||||
|
|
||||||
mainEvents.forEach(function(event) {
|
mainEvents.forEach(function(event) {
|
||||||
@ -237,14 +237,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var requests_data = {
|
var requests_data = {
|
||||||
"max": {{ collector.events.section.endtime }},
|
"max": {{ collector.events.__section__.endtime }},
|
||||||
"requests": [
|
"requests": [
|
||||||
{{ _self.dump_request_data(token, profile, collector.events, collector.events.section.origin) }}
|
{{ _self.dump_request_data(token, profile, collector.events, collector.events.__section__.origin) }}
|
||||||
|
|
||||||
{% if profile.children|length %}
|
{% if profile.children|length %}
|
||||||
,
|
,
|
||||||
{% for child in profile.children %}
|
{% for child in profile.children %}
|
||||||
{{ _self.dump_request_data(child.token, child, child.getcollector('time').events, collector.events.section.origin) }}{{ loop.last ? '' : ',' }}
|
{{ _self.dump_request_data(child.token, child, child.getcollector('time').events, collector.events.__section__.origin) }}{{ loop.last ? '' : ',' }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
]
|
]
|
||||||
@ -257,7 +257,7 @@
|
|||||||
{% macro dump_request_data(token, profile, events, origin) %}
|
{% macro dump_request_data(token, profile, events, origin) %}
|
||||||
{
|
{
|
||||||
"id": "{{ token }}",
|
"id": "{{ token }}",
|
||||||
"left": {{ events.section.origin - origin }},
|
"left": {{ events.__section__.origin - origin }},
|
||||||
"events": [
|
"events": [
|
||||||
{{ _self.dump_events(events) }}
|
{{ _self.dump_events(events) }}
|
||||||
]
|
]
|
||||||
@ -266,7 +266,7 @@
|
|||||||
|
|
||||||
{% macro dump_events(events) %}
|
{% macro dump_events(events) %}
|
||||||
{% for name, event in events %}
|
{% for name, event in events %}
|
||||||
{% if 'section' != name %}
|
{% if '__section__' != name %}
|
||||||
{
|
{
|
||||||
"name": "{{ name }}",
|
"name": "{{ name }}",
|
||||||
"category": "{{ event.category }}",
|
"category": "{{ event.category }}",
|
||||||
@ -286,7 +286,7 @@
|
|||||||
|
|
||||||
{% macro display_timeline(id, events, threshold, colors, width) %}
|
{% macro display_timeline(id, events, threshold, colors, width) %}
|
||||||
{% set height = 0 %}
|
{% set height = 0 %}
|
||||||
{% for name, event in events if 'section' != name and event.totaltime >= threshold %}
|
{% for name, event in events if '__section__' != name and event.totaltime >= threshold %}
|
||||||
{% set height = height + 38 %}
|
{% set height = height + 38 %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class TimeDataCollector extends DataCollector
|
|||||||
*/
|
*/
|
||||||
public function getTotalTime()
|
public function getTotalTime()
|
||||||
{
|
{
|
||||||
$lastEvent = $this->data['events']['section'];
|
$lastEvent = $this->data['events']['__section__'];
|
||||||
|
|
||||||
return $lastEvent->getOrigin() + $lastEvent->getTotalTime() - $this->data['start_time'];
|
return $lastEvent->getOrigin() + $lastEvent->getTotalTime() - $this->data['start_time'];
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ class TimeDataCollector extends DataCollector
|
|||||||
*/
|
*/
|
||||||
public function getInitTime()
|
public function getInitTime()
|
||||||
{
|
{
|
||||||
return $this->data['events']['section']->getOrigin() - $this->getStartTime();
|
return $this->data['events']['__section__']->getOrigin() - $this->getStartTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,14 +29,14 @@ class Stopwatch
|
|||||||
public function startSection()
|
public function startSection()
|
||||||
{
|
{
|
||||||
if ($this->events) {
|
if ($this->events) {
|
||||||
$this->start('section.child', 'section');
|
$this->start('__section__.child', 'section');
|
||||||
$this->waiting[] = array($this->events, $this->origin);
|
$this->waiting[] = array($this->events, $this->origin);
|
||||||
$this->events = array();
|
$this->events = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->origin = microtime(true) * 1000;
|
$this->origin = microtime(true) * 1000;
|
||||||
|
|
||||||
$this->start('section');
|
$this->start('__section__');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +50,7 @@ class Stopwatch
|
|||||||
*/
|
*/
|
||||||
public function stopSection($id)
|
public function stopSection($id)
|
||||||
{
|
{
|
||||||
$this->stop('section');
|
$this->stop('__section__');
|
||||||
|
|
||||||
if (null !== $id) {
|
if (null !== $id) {
|
||||||
$this->sections[$id] = $this->events;
|
$this->sections[$id] = $this->events;
|
||||||
@ -58,7 +58,7 @@ class Stopwatch
|
|||||||
|
|
||||||
if ($this->waiting) {
|
if ($this->waiting) {
|
||||||
list($this->events, $this->origin) = array_pop($this->waiting);
|
list($this->events, $this->origin) = array_pop($this->waiting);
|
||||||
$this->stop('section.child');
|
$this->stop('__section__.child');
|
||||||
} else {
|
} else {
|
||||||
$this->origin = null;
|
$this->origin = null;
|
||||||
$this->events = array();
|
$this->events = array();
|
||||||
|
Reference in New Issue
Block a user