minor #38409 [Stopwatch] Added example to the README (wouterj)

This PR was merged into the 4.4 branch.

Discussion
----------

[Stopwatch] Added example to the README

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | https://github.com/symfony/symfony-docs/pull/14333

Commits
-------

e2461c90d2 Added Stopwatch example to the README
This commit is contained in:
Fabien Potencier 2020-10-04 17:43:30 +02:00
commit 619509e3c3

View File

@ -3,10 +3,39 @@ Stopwatch Component
The Stopwatch component provides a way to profile code.
Getting Started
---------------
```
$ composer require symfony/stopwatch
```
```php
use Symfony\Component\Stopwatch\Stopwatch;
$stopwatch = new Stopwatch();
// optionally group events into sections (e.g. phases of the execution)
$stopwatch->openSection();
// starts event named 'eventName'
$stopwatch->start('eventName');
// ... run your code here
// optionally, start a new "lap" time
$stopwatch->lap('foo');
// ... run your code here
$event = $stopwatch->stop('eventName');
$stopwatch->stopSection('phase_1');
```
Resources
---------
* [Documentation](https://symfony.com/doc/current/components/stopwatch.html)
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
* [Report issues](https://github.com/symfony/symfony/issues) and
[send Pull Requests](https://github.com/symfony/symfony/pulls)