Documentation

Stopwatch
in package
implements ResetInterface

Stopwatch provides a way to profile code.

Tags
author

Fabien Potencier fabien@symfony.com

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

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

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>

isStarted()

Checks if the event was started.

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

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
throws
LogicException

When the section to re-open is not reachable

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|null $category = null ]) : StopwatchEvent
Parameters
$name : string
$category : string|null = null
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
Tags
see
getSectionEvents()
throws
LogicException

When there's no started section to be stopped

Return values
mixed

Search results