8000 [#1959] Tweaks for new stopwatch component docs · T4m/symfony-docs@4b0ad60 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b0ad60

Browse files
committed
[symfony#1959] Tweaks for new stopwatch component docs
1 parent 59a3258 commit 4b0ad60

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

components/stopwatch.rst

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ The Stopwatch Component
77

88
Stopwatch component provides a way to profile code.
99

10+
.. versionadded:: 2.2
11+
The Stopwatch Component is new to Symfony 2.2. Previously, the ``Stopwatch``
12+
class was located in the ``HttpKernel`` component.
13+
1014
Installation
1115
------------
1216

@@ -19,8 +23,9 @@ Usage
1923
-----
2024

2125
The Stopwatch component provides an easy and consistent way to measure execution
22-
time of certain parts of code, so that you don't constantly have to parse
23-
microtime by yourself. The basic usage is as simple as this::
26+
time of certain parts of code so that you don't constantly have to parse
27+
microtime by yourself. Instead, use the simple
28+
:class:`Symfony\\Component\\Stopwatch\\Stopwatch` class::
2429

2530
use Symfony\Component\Stopwatch\Stopwatch;
2631

@@ -35,14 +40,15 @@ You also can provide a category name to an event::
3540
$stopwatch->start('eventName', 'categoryName');
3641

3742
You can consider categories as a way of tagging events. The Symfony Profiler
38-
tool uses categories to nicely colorcode different events.
43+
tool, for example, uses categories to nicely color-code different events.
3944

4045
Periods
4146
-------
4247

43-
As we all know from the real world, all stopwatches come with two buttons.
48+
As you know from the real world, all stopwatches come with two buttons.
4449
One for starting and stopping the stopwatch, another to measure the lap time.
45-
And that's exactly what lap method does. ::
50+
This is exactly what the :method:`Symfony\\Component\\Stopwatch\\Stopwatch::lap``
51+
method does::
4652

4753
$stopwatch = new Stopwatch();
4854
// Start event named 'foo'
@@ -54,39 +60,39 @@ And that's exactly what lap method does. ::
5460
// some other code goes here
5561
$event = $stopwatch->stop('foo');
5662

57-
Lap information is stored in periods within the event. To get lap information aka periods call ::
63+
Lap information is stored in periods within the event. To get lap information
64+
(aka periods) call::
5865

5966
$event->getPeriods();
6067

61-
Besides getting periods, we can get other useful information from the event object. E.g::
68+
Besides getting periods, you can get other useful information from the event object.
69+
For example::
6270

6371
$event->getCategory(); // Returns the category the evenent was started in
6472
$event->getOrigin(); // Returns the start time of the Event in milliseconds
65-
$event->ensureStopped(); // Stops all non already stopped periods
73+
$event->ensureStopped(); // Stops all not-already-stopped periods
6674
$event->getStartTime(); // Returns the start of the very first period
6775
$event->getEndTime(); // Returns the end time of the very last period
6876
$event->getDuration(); // Gets the duration (including all periods) of the event
6977
$event->getMemory(); // Gets the max memory usage of all periods
7078

71-
7279
Sections
7380
--------
7481

7582
Sections are a way to logically split the timeline into groups. You can see
7683
how Symfony uses sections to nicely visualize framework lifecycle in the
77-
Symfony Profiler tool. Here is a basic usage of sections.::
84+
Symfony Profiler tool. Here is a basic usage of sections::
7885

7986
$stopwatch = new Stopwatch();
8087

8188
$stopwatch->openSection();
82-
$stopwatch->start('parisng_config_file', 'filesystem_operations');
89+
$stopwatch->start('parsing_config_file', 'filesystem_operations');
8390
$stopwatch->stopSection('routing');
8491

85-
$events = $stopwatch->getSectionEvents('section');
86-
92+
$events = $stopwatch->getSectionEvents('routing');
8793

8894
You can reopen a closed section by calling the openSection method and specifying
89-
an id of the section to be reopened. e.g.::
95+
an id of the section to be reopened::
9096

9197
$stopwatch->openSection('routing');
9298
$stopwatch->start('building_config_tree');

0 commit comments

Comments
 (0)
0