modified Profiler to clear queries array on start()

This commit is contained in:
Anton Grebnev
2012-10-05 19:39:45 +04:00
parent 5bc65513eb
commit 774c86acd2
2 changed files with 4 additions and 2 deletions

View File

@ -95,9 +95,10 @@ class ProfilerTest extends PHPUnit_Framework_TestCase
$this->getMock('CommandProfiler', array('getType', 'getCommand', 'getElapsed'), array(), 'CommandProfilerMock', false); $this->getMock('CommandProfiler', array('getType', 'getCommand', 'getElapsed'), array(), 'CommandProfilerMock', false);
$profiler = Profiler::getInstance(); $profiler = Profiler::getInstance();
$cmdProfiler = $profiler->profilerCommand('command', 'type');
$profiler->start(); $profiler->start();
$cmdProfiler = $profiler->profilerCommand('command', 'type');
$this->assertNotNull($cmdProfiler);
$result = $profiler->end('<body></body>'); $result = $profiler->end('<body></body>');
$this->assertNotEquals('<body></body>', $result); $this->assertNotEquals('<body></body>', $result);
$this->assertStringEndsNotWith(']<br/></div></body>', $result); $this->assertStringEndsNotWith(']<br/></div></body>', $result);
@ -130,8 +131,8 @@ class ProfilerTest extends PHPUnit_Framework_TestCase
$this->getMock('CommandProfiler', array('getType', 'getCommand', 'getElapsed'), array(), 'CommandProfilerMock', false); $this->getMock('CommandProfiler', array('getType', 'getCommand', 'getElapsed'), array(), 'CommandProfilerMock', false);
$profiler = Profiler::getInstance(); $profiler = Profiler::getInstance();
$cmdProfiler = $profiler->profilerCommand('command', 'type');
$profiler->start(); $profiler->start();
$cmdProfiler = $profiler->profilerCommand('command', 'type');
$result = $profiler->end('<body></body>'); $result = $profiler->end('<body></body>');
$this->assertNotEquals('<body></body>', $result); $this->assertNotEquals('<body></body>', $result);
$this->assertStringEndsNotWith(']<br/></div></body>', $result); $this->assertStringEndsNotWith(']<br/></div></body>', $result);

View File

@ -59,6 +59,7 @@ class Profiler
public function start() public function start()
{ {
$this->queries = array();
$this->start = microtime(true); $this->start = microtime(true);
} }