Stopwatch
in package
implements
ResetInterface
Stopwatch provides a way to profile code.
Tags
Interfaces, Classes and Traits
- ResetInterface
- Provides a way to reset an object to its initial state.
Table of Contents
- $activeSections : array<string|int, Section>
- $morePrecision : bool
- $sections : array<string|int, Section>
- __construct() : mixed
- getEvent() : StopwatchEvent
- Returns a specific event by name.
- getSectionEvents() : array<string|int, StopwatchEvent>
- Gets all events for a given section.
- getSections() : array<string|int, Section>
- isStarted() : bool
- Checks if the event was started.
- lap() : StopwatchEvent
- Stops then restarts an event.
- openSection() : mixed
- Creates a new section or re-opens an existing section.
- reset() : mixed
- Resets the stopwatch to its original state.
- start() : StopwatchEvent
- Starts an event.
- stop() : StopwatchEvent
- Stops an event.
- stopSection() : mixed
- Stops the last started section.
Properties
$activeSections
private
array<string|int, Section>
$activeSections
$morePrecision
private
bool
$morePrecision
$sections
private
array<string|int, Section>
$sections
Methods
__construct()
public
__construct([bool $morePrecision = false ]) : mixed
Parameters
- $morePrecision : bool = false
-
If true, time is stored as float to keep the original microsecond precision
Return values
mixed —getEvent()
Returns a specific event by name.
public
getEvent(string $name) : StopwatchEvent
Parameters
- $name : string
Return values
StopwatchEvent —getSectionEvents()
Gets all events for a given section.
public
getSectionEvents(string $id) : array<string|int, StopwatchEvent>
Parameters
- $id : string
Return values
array<string|int, StopwatchEvent> —getSections()
public
getSections() : array<string|int, Section>
Return values
array<string|int, Section> —isStarted()
Checks if the event was started.
public
isStarted(string $name) : bool
Parameters
- $name : string
Return values
bool —lap()
Stops then restarts an event.
public
lap(string $name) : StopwatchEvent
Parameters
- $name : string
Return values
StopwatchEvent —openSection()
Creates a new section or re-opens an existing section.
public
openSection([string|null $id = null ]) : mixed
Parameters
- $id : string|null = null
-
The id of the session to re-open, null to create a new one
Tags
Return values
mixed —reset()
Resets the stopwatch to its original state.
public
reset() : mixed
Return values
mixed —start()
Starts an event.
public
start(string $name[, string $category = null ]) : StopwatchEvent
Parameters
- $name : string
- $category : string = null
Return values
StopwatchEvent —stop()
Stops an event.
public
stop(string $name) : StopwatchEvent
Parameters
- $name : string
Return values
StopwatchEvent —stopSection()
Stops the last started section.
public
stopSection(string $id) : mixed
The id parameter is used to retrieve the events from this section.
Parameters
- $id : string