This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Stopwatch
Nicolas Grekas 1a0ea4d2f7 Merge branch '4.4' into 5.1
* 4.4:
  Fix branch-version
2020-10-13 15:21:37 +02:00
..
Tests Merge branch '3.4' into 4.3 2019-11-05 15:48:09 +01:00
.gitattributes add missing gitattributes for phpunit-bridge 2020-03-27 17:54:36 +01:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md [Stopwatch] fix wrong nullable type 2019-07-29 18:24:06 +02:00
composer.json Merge branch '4.4' into 5.1 2020-10-13 15:21:37 +02:00
LICENSE Update year in license files 2020-01-01 12:03:25 +01:00
phpunit.xml.dist Bump phpunit XSD version to 5.2 2018-11-11 12:18:13 +01:00
README.md Added Stopwatch example to the README 2020-10-04 14:01:13 +02:00
Section.php Merge branch '3.4' into 4.4 2020-09-02 18:08:58 +02:00
Stopwatch.php Merge branch '4.4' into 5.0 2020-03-18 09:00:37 +01:00
StopwatchEvent.php Add missing dots at the end of exception messages 2020-03-15 10:38:08 +01:00
StopwatchPeriod.php Replace more docblocks by type-hints 2017-11-07 15:45:01 +01:00

Stopwatch Component

The Stopwatch component provides a way to profile code.

Getting Started

$ composer require symfony/stopwatch
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