Debug::timer()
Measure time between two events
First call should be to $timer = Debug with no arguments, or provide your own key/name as an argument.
Second call should pass the $timer given by the first call to get the time elapsed, i.e. $elapsed = Debug.
Note that you may make multiple calls back to Debug with the same key and it will continue returning the elapsed time since the original call. If you want
to reset or remove the timer, call removeTimer or resetTimer.
Example
// typical usage
$timer = Debug::timer();
some_code_that_you_want_to_time();
$seconds = Debug::timer($timer);
// using a named timer
Debug::timer('foobar');
some_code_that_you_want_to_time();
$seconds = Debug::timer('foobar');
// optionally remove the timer
Debug::removeTimer('foobar'); Usage
// basic usage
$string = Debug::timer();
// usage with all arguments
$string = Debug::timer(string $key = '', bool $reset = false);Arguments
| Name | Type(s) | Description |
|---|---|---|
$key (optional) | string | Leave blank to start timer. Specify existing key (string) to return timer. Specify new made up key to start a named timer. |
$reset (optional) | bool | If the timer already exists, it will be reset when this is true. |
Return value
string int
API reference based on ProcessWire core version 3.0.257