Skip to content

Commit a4fe875

Browse files
committed
minor #8146 Added a tip about the support of microseconds in Stopwatch (javiereguiluz)
This PR was squashed before being merged into the 3.4 branch (closes #8146). Discussion ---------- Added a tip about the support of microseconds in Stopwatch This documents symfony/symfony#23223. See also https://symfony.com/blog/new-in-symfony-3-4-stopwatch-improvements. Commits ------- 24718a6 Added a tip about the support of microseconds in Stopwatch
2 parents 5825559 + 24718a6 commit a4fe875

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

components/stopwatch.rst

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,24 @@ microtime by yourself. Instead, use the simple
3434
$event = $stopwatch->stop('eventName');
3535

3636
The :class:`Symfony\\Component\\Stopwatch\\StopwatchEvent` object can be retrieved
37-
from the :method:`Symfony\\Component\\Stopwatch\\Stopwatch::start`,
38-
:method:`Symfony\\Component\\Stopwatch\\Stopwatch::stop`,
39-
:method:`Symfony\\Component\\Stopwatch\\Stopwatch::lap` and
40-
:method:`Symfony\\Component\\Stopwatch\\Stopwatch::getEvent` methods.
37+
from the :method:`Symfony\\Component\\Stopwatch\\Stopwatch::start`,
38+
:method:`Symfony\\Component\\Stopwatch\\Stopwatch::stop`,
39+
:method:`Symfony\\Component\\Stopwatch\\Stopwatch::lap` and
40+
:method:`Symfony\\Component\\Stopwatch\\Stopwatch::getEvent` methods.
4141
The latter should be used when you need to retrieve the duration of an event
4242
while it is still running.
4343

44+
.. tip::
45+
46+
By default, the stopwatch truncates any sub-millisecond time measure to ``0``,
47+
so you can't measure microseconds or nanoseconds. If you need more precision,
48+
pass ``true`` to the ``Stopwatch`` class constructor to enable full precision::
49+
50+
$stopwatch = new Stopwatch(true);
51+
52+
.. versionadded:: 3.4
53+
The full precision feature was introduced in Symfony 3.4.
54+
4455
You can also provide a category name to an event::
4556

4657
$stopwatch->start('eventName', 'categoryName');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy