W3cubDocs

/Symfony 3.0

Symfony\Component\Stopwatch\Stopwatch

class Stopwatch

Stopwatch provides a way to profile code.

Methods

__construct()
Section[] getSections()
openSection(string|null $id = null)

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

stopSection(string $id)

Stops the last started section.

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

Starts an event.

bool isStarted(string $name)

Checks if the event was started.

StopwatchEvent stop(string $name)

Stops an event.

StopwatchEvent lap(string $name)

Stops then restarts an event.

StopwatchEvent getEvent(string $name)

Returns a specific event by name.

StopwatchEvent[] getSectionEvents(string $id)

Gets all events for a given section.

Details

public __construct()

public Section[] getSections()

Return Value

Section[]

public 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

public 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()

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

Starts an event.

Parameters

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

Return Value

StopwatchEvent A StopwatchEvent instance

public bool isStarted(string $name)

Checks if the event was started.

Parameters

string $name The event name

Return Value

bool

public StopwatchEvent stop(string $name)

Stops an event.

Parameters

string $name The event name

Return Value

StopwatchEvent A StopwatchEvent instance

public StopwatchEvent lap(string $name)

Stops then restarts an event.

Parameters

string $name The event name

Return Value

StopwatchEvent A StopwatchEvent instance

public StopwatchEvent getEvent(string $name)

Returns a specific event by name.

Parameters

string $name The event name

Return Value

StopwatchEvent A StopwatchEvent instance

public StopwatchEvent[] getSectionEvents(string $id)

Gets all events for a given section.

Parameters

string $id A section identifier

Return Value

StopwatchEvent[] An array of StopwatchEvent instances

© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.0/Symfony/Component/Stopwatch/Stopwatch.html