Documentation

Timer
in package

Class Timer

Provides a simple way to measure the amount of time that elapses between two points.

Table of Contents

$timers  : array<string|int, mixed>
List of all timers.
getElapsedTime()  : null|float
Returns the duration of a recorded timer.
getTimers()  : array<string|int, mixed>
Returns the array of timers, with the duration pre-calculated for you.
has()  : bool
Checks whether or not a timer with the specified name exists.
start()  : Timer
Starts a timer running.
stop()  : Timer
Stops a running timer.

Properties

$timers

List of all timers.

protected array<string|int, mixed> $timers = []

Methods

getElapsedTime()

Returns the duration of a recorded timer.

public getElapsedTime(string $name[, int $decimals = 4 ]) : null|float
Parameters
$name : string

The name of the timer.

$decimals : int = 4

Number of decimal places.

Return values
null|float

Returns null if timer exists by that name. Returns a float representing the number of seconds elapsed while that timer was running.

getTimers()

Returns the array of timers, with the duration pre-calculated for you.

public getTimers([int $decimals = 4 ]) : array<string|int, mixed>
Parameters
$decimals : int = 4

Number of decimal places

Return values
array<string|int, mixed>

has()

Checks whether or not a timer with the specified name exists.

public has(string $name) : bool
Parameters
$name : string
Return values
bool

start()

Starts a timer running.

public start(string $name[, float $time = null ]) : Timer

Multiple calls can be made to this method so that several execution points can be measured.

Parameters
$name : string

The name of this timer.

$time : float = null

Allows user to provide time.

Return values
Timer

stop()

Stops a running timer.

public stop(string $name) : Timer

If the timer is not stopped before the timers() method is called, it will be automatically stopped at that point.

Parameters
$name : string

The name of this timer.

Return values
Timer

Search results