Added pssibility to reset the profiler.

This commit is contained in:
Alexander M. Turek
2017-09-22 16:29:04 +02:00
parent cd06d3c696
commit ea922bb6eb
2 changed files with 16 additions and 0 deletions
+6
View File
@@ -145,6 +145,12 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
);
}
public function reset()
{
$this->starts = $this->ends = $this->profiles = array();
$this->enter();
}
public function getIterator()
{
return new ArrayIterator($this->profiles);
+10
View File
@@ -97,4 +97,14 @@ class Twig_Tests_Profiler_ProfileTest extends \PHPUnit\Framework\TestCase
$this->assertEquals($profile1->getType(), $profile3->getType());
$this->assertEquals($profile1->getName(), $profile3->getName());
}
public function testReset()
{
$profile = new Twig_Profiler_Profile();
usleep(1);
$profile->leave();
$profile->reset();
$this->assertEquals(0, $profile->getDuration());
}
}