mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 19:36:43 +00:00
bug #1825 Profiler root duration fix (fabpot)
This PR was merged into the 1.x branch.
Discussion
----------
Profiler root duration fix
When using the Twig profiler, the root node is a bit special and the duration should really be the sum of the children duration. That should fix #1792
Commits
-------
f1e963c fixed the profiler duration for the root node
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
* 1.22.0 (2015-XX-XX)
|
||||
|
||||
* fixed the profiler duration for the root node
|
||||
* changed template cache names to take into account enabled extensions
|
||||
* deprecated Twig_Environment::clearCacheFiles(), Twig_Environment::getCacheFilename(),
|
||||
Twig_Environment::writeCacheFile(), and Twig_Environment::getTemplateClassPrefix()
|
||||
|
||||
@@ -86,6 +86,16 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
|
||||
*/
|
||||
public function getDuration()
|
||||
{
|
||||
if ($this->isRoot() && $this->profiles) {
|
||||
// for the root node with children, duration is the sum of all child durations
|
||||
$duration = 0;
|
||||
foreach ($this->profiles as $profile) {
|
||||
$duration += $profile->getDuration();
|
||||
}
|
||||
|
||||
return $duration;
|
||||
}
|
||||
|
||||
return isset($this->ends['wt']) && isset($this->starts['wt']) ? $this->ends['wt'] - $this->starts['wt'] : 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user