Skip to content

Commit 73c11a7

Browse files
bug #23539 [Stopwatch] Fix precision for root section (gharlan)
This PR was squashed before being merged into the 3.4 branch (closes #23539). Discussion ---------- [Stopwatch] Fix precision for root section | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- b2c0dc3 [Stopwatch] Fix precision for root section
2 parents b24a338 + b2c0dc3 commit 73c11a7

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)