Stopwatch
in package
implements
ResetInterface
Stopwatch provides a way to profile code.
Tags
Table of Contents
Interfaces
- ResetInterface
- Provides a way to reset an object to its initial state.
Properties
- $activeSections : array<string|int, Section>
- $morePrecision : bool
- $sections : array<string|int, Section>
Methods
- __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() : void
- Creates a new section or re-opens an existing section.
- reset() : void
- Resets the stopwatch to its original state.
- start() : StopwatchEvent
- Starts an event.
- stop() : StopwatchEvent
- Stops an event.
- stopSection() : void
- Stops the last started section.
Properties
$activeSections
private
array<string|int, Section>
$activeSections
$morePrecision
private
bool
$morePrecision
= false
$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
getEvent()
Returns a specific event by name.
public
getEvent(string $name) : StopwatchEvent
Parameters
- $name : string
Return values
StopwatchEventgetSectionEvents()
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
boollap()
Stops then restarts an event.
public
lap(string $name) : StopwatchEvent
Parameters
- $name : string
Return values
StopwatchEventopenSection()
Creates a new section or re-opens an existing section.
public
openSection([string|null $id = null ]) : void
Parameters
- $id : string|null = null
-
The id of the session to re-open, null to create a new one
Tags
reset()
Resets the stopwatch to its original state.
public
reset() : void
start()
Starts an event.
public
start(string $name[, string|null $category = null ]) : StopwatchEvent
Parameters
- $name : string
- $category : string|null = null
Return values
StopwatchEventstop()
Stops an event.
public
stop(string $name) : StopwatchEvent
Parameters
- $name : string
Return values
StopwatchEventstopSection()
Stops the last started section.
public
stopSection(string $id) : void
The id parameter is used to retrieve the events from this section.
Parameters
- $id : string