Skip to content

Commit b2c0dc3

Browse files
gharlannicolas-grekas
authored andcommitted
[Stopwatch] Fix precision for root section
1 parent b24a338 commit b2c0dc3

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Component/Stopwatch/Stopwatch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class Stopwatch
3838
*/
3939
public function __construct($morePrecision = false)
4040
{
41-
$this->reset();
4241
$this->morePrecision = $morePrecision;
42+
$this->reset();
4343
}
4444

4545
/**

src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ public function testStopWithoutStart()
100100
$stopwatch->stop('foo');
101101
}
102102

103+
public function testMorePrecision()
104+
{
105+
$stopwatch = new Stopwatch(true);
106+
107+
$stopwatch->start('foo');
108+
$event = $stopwatch->stop('foo');
109+
110+
$this->assertInternalType('float', $event->getStartTime());
111+
$this->assertInternalType('float', $event->getEndTime());
112+
$this->assertInternalType('float', $event->getDuration());
113+
}
114+
103115
public function testSection()
104116
{
105117
$stopwatch = new Stopwatch();

0 commit comments

Comments
 (0)