From e2461c90d2367a491b085a2b1c9476e9df14c2ce Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sun, 4 Oct 2020 14:01:13 +0200 Subject: [PATCH] Added Stopwatch example to the README --- src/Symfony/Component/Stopwatch/README.md | 31 ++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Stopwatch/README.md b/src/Symfony/Component/Stopwatch/README.md index eb0ebb3fa8..4c3cb7ecb3 100644 --- a/src/Symfony/Component/Stopwatch/README.md +++ b/src/Symfony/Component/Stopwatch/README.md @@ -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)