Documentation

Stopwatch
in package
implements ResetInterface

Stopwatch provides a way to profile code.

Tags
author

Fabien Potencier fabien@symfony.com

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

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

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 ]) : void
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

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
StopwatchEvent

stopSection()

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
Tags
see
getSectionEvents()
throws
LogicException

When there's no started section to be stopped


        
On this page

Search results