Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

symfony/stopwatch v7.0.3

Provides a way to profile code
Package summary
Share
0
issues
0
licenses
Package created
10 Nov 2012
Version published
23 Jan 2024
Maintainers
1
Total deps
0
Direct deps
0
License
MIT
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does symfony/stopwatch do?

The symfony/stopwatch is a PHP-based Composer package that provides an efficient way to profile code. If you are looking for a tool to time parts of your code and calculate the duration of PHP processes, symfony/stopwatch is an excellent tool worth considering. It allows not just the configuration and starting the stopwatch, but also opening sections for specific, grouped events and stopping sections or individual events, and determining 'lap' times.

How do you use symfony/stopwatch?

To start using symfony/stopwatch, you will first need to add it to your project through Composer. Run the following command to install:

$ composer require symfony/stopwatch

After installation, you can use it in your PHP code as follows:

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');

In this example, an instance of Stopwatch is created and a section is opened. An event is started named 'eventName', then a lap is set with 'foo'. After running some more code, the event 'eventName' is stopped along with the section 'phase_1'.

Keep in mind that specific processes or blocks of code to be timed need to be placed where the comment // ... run your code here is.

Where are the symfony/stopwatch docs?

While the symfony/stopwatch readme provides initial usage information, in the package's main repository, https://github.com/symfony/stopwatch.git, you can find links for further information and resources. For in-depth documentation about Symfony's Stopwatch component, visit Symfony's official website. If you wish to contribute to the package or report issues, follow the links provided in the readme to the main Symfony repository and associated GitHub pages.