class Stopwatch

Stopwatch provides a way to profile code.

Methods

__construct(bool $morePrecision = false)

No description

getSections()

No description

openSection(string|null $id = null)

Creates a new section or re-opens an existing section.

stopSection(string $id)

Stops the last started section.

start(string $name, string $category = null)

Starts an event.

bool
isStarted(string $name)

Checks if the event was started.

stop(string $name)

Stops an event.

lap(string $name)

Stops then restarts an event.

getEvent(string $name)

Returns a specific event by name.

getSectionEvents(string $id)

Gets all events for a given section.

reset()

Resets the stopwatch to its original state.

Details

at line line 39
__construct(bool $morePrecision = false)

Parameters

bool $morePrecision If true, time is stored as float to keep the original microsecond precision

at line line 48
Section[] getSections()

Return Value

Section[]

at line line 60
openSection(string|null $id = null)

Creates a new section or re-opens an existing section.

Parameters

string|null $id The id of the session to re-open, null to create a new one

Exceptions

LogicException When the section to re-open is not reachable

at line line 84
stopSection(string $id)

Stops the last started section.

The id parameter is used to retrieve the events from this section.

Parameters

string $id The identifier of the section

Exceptions

LogicException When there's no started section to be stopped

See also

getSectionEvents()

at line line 104
StopwatchEvent start(string $name, string $category = null)

Starts an event.

Parameters

string $name The event name
string $category The event category

Return Value

StopwatchEvent

at line line 116
bool isStarted(string $name)

Checks if the event was started.

Parameters

string $name The event name

Return Value

bool

at line line 128
StopwatchEvent stop(string $name)

Stops an event.

Parameters

string $name The event name

Return Value

StopwatchEvent

at line line 140
StopwatchEvent lap(string $name)

Stops then restarts an event.

Parameters

string $name The event name

Return Value

StopwatchEvent

at line line 152
StopwatchEvent getEvent(string $name)

Returns a specific event by name.

Parameters

string $name The event name

Return Value

StopwatchEvent

at line line 164
StopwatchEvent[] getSectionEvents(string $id)

Gets all events for a given section.

Parameters

string $id A section identifier

Return Value

StopwatchEvent[]

at line line 172
reset()

Resets the stopwatch to its original state.