| 1 |
Stopwatch Component |
| 2 |
=================== |
| 3 |
|
| 4 |
The Stopwatch component provides a way to profile code. |
| 5 |
|
| 6 |
Getting Started |
| 7 |
--------------- |
| 8 |
|
| 9 |
``` |
| 10 |
$ composer require symfony/stopwatch |
| 11 |
``` |
| 12 |
|
| 13 |
```php |
| 14 |
use Symfony\Component\Stopwatch\Stopwatch; |
| 15 |
|
| 16 |
$stopwatch = new Stopwatch(); |
| 17 |
|
| 18 |
// optionally group events into sections (e.g. phases of the execution) |
| 19 |
$stopwatch->openSection(); |
| 20 |
|
| 21 |
// starts event named 'eventName' |
| 22 |
$stopwatch->start('eventName'); |
| 23 |
|
| 24 |
// ... run your code here |
| 25 |
|
| 26 |
// optionally, start a new "lap" time |
| 27 |
$stopwatch->lap('foo'); |
| 28 |
|
| 29 |
// ... run your code here |
| 30 |
|
| 31 |
$event = $stopwatch->stop('eventName'); |
| 32 |
|
| 33 |
$stopwatch->stopSection('phase_1'); |
| 34 |
``` |
| 35 |
|
| 36 |
Resources |
| 37 |
--------- |
| 38 |
|
| 39 |
* [](https://symfony.com/doc/current/contributing/index.htmlContributing](https://symfony.com/doc/current/contributing/index.html](https://symfony.com/doc/current/contributing/index.html) |
| 40 |
* [](https://github.com/symfony/symfony/issuesReport issues](https://github.com/symfony/symfony/issues](https://github.com/symfony/symfony/issues) and |
| 41 |
[](https://github.com/symfony/symfony/pullssend Pull Requests](https://github.com/symfony/symfony/pulls](https://github.com/symfony/symfony/pulls) |
| 42 |
in the [](https://github.com/symfony/symfonymain Symfony repository](https://github.com/symfony/symfony](https://github.com/symfony/symfony) |
| 43 |
|