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
2727 use Symfony\Component\Stopwatch\Stopwatch;
2828
2929 $stopwatch = new Stopwatch();
30+
3031 // starts event named 'eventName'
3132 $stopwatch->start('eventName');
32- // ... some code goes here
33+
34+ // ... run your code here
35+
3336 $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'
3439
3540The :class: `Symfony\\ Component\\ Stopwatch\\ StopwatchEvent ` object can be retrieved
3641from the :method: `Symfony\\ Component\\ Stopwatch\\ Stopwatch::start `,
@@ -120,16 +125,3 @@ method and specifying the id of the section to be reopened::
120125 $stopwatch->openSection('routing');
121126 $stopwatch->start('building_config_tree');
122127 $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