Stopwatch
*********
Another useful tool is the debugger stopwatch with nanosecond precision:
```php
Debugger::timer();
// sweet dreams my cherrie
sleep(2);
$elapsed = Debugger::timer();
// $elapsed = 2
```
Multiple measurements can be achieved using an optional parameter as an identifier.
```php
Debugger::timer('page-generating');
// some code
Debugger::timer('rss-generating');
// some code
$rssElapsed = Debugger::timer('rss-generating');
$pageElapsed = Debugger::timer('page-generating');
```
```php
Debugger::timer(); // runs the timer
// ... some time-consuming operation
echo Debugger::timer(); // elapsed time in seconds
```
{{maintitle: Measure PHP Execution Time with the Tracy Stopwatch}}
{{description: Measure how long your PHP code takes with the Tracy stopwatch: nanosecond precision, several independent timers and a simple call to Debugger::timer().}}
Stopwatch
Another useful tool is the debugger stopwatch with nanosecond precision:
Debugger::timer();
// sweet dreams my cherrie
sleep(2);
$elapsed = Debugger::timer();
// $elapsed = 2
Multiple measurements can be achieved using an optional parameter as an identifier.
Debugger::timer('page-generating');
// some code
Debugger::timer('rss-generating');
// some code
$rssElapsed = Debugger::timer('rss-generating');
$pageElapsed = Debugger::timer('page-generating');
Debugger::timer(); // runs the timer
// ... some time-consuming operation
echo Debugger::timer(); // elapsed time in seconds