File tree Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,15 @@ time of certain parts of code so that you don't constantly have to parse
27
27
use Symfony\Component\Stopwatch\Stopwatch;
28
28
29
29
$stopwatch = new Stopwatch();
30
+
30
31
// starts event named 'eventName'
31
32
$stopwatch->start('eventName');
32
- // ... some code goes here
33
+
34
+ // ... run your code here
35
+
33
36
$event = $stopwatch->stop('eventName');
37
+ // you can convert $event into a string for a quick summary
38
+ // e.g. (string) $event = '4.50 MiB - 26 ms'
34
39
35
40
The :class: `Symfony\\ Component\\ Stopwatch\\ StopwatchEvent ` object can be retrieved
36
41
from the :method: `Symfony\\ Component\\ Stopwatch\\ Stopwatch::start `,
@@ -120,16 +125,3 @@ method and specifying the id of the section to be reopened::
120
125
$stopwatch->openSection('routing');
121
126
$stopwatch->start('building_config_tree');
122
127
$stopwatch->stopSection('routing');
123
-
124
-
125
- Printing a Summary
126
- ------------------
127
-
128
- The event can easily be printed to display a summary::
129
-
130
- $stopwatch = new Stopwatch();
131
- $stopwatch->start();
132
- // ... do some work here
133
- $output->writeln($stopwatch->stop()); // prints something like default: 14.00 MiB - 2056 ms
134
-
135
- This gives you a brief summary of the used memory an elapsed time.
You can’t perform that action at this time.
0 commit comments