Profiler

Implements ProfilerInterface, IteratorAggregate, Countable

Implementation of ProfilerInterface.

since

1.0

package

Joomla Framework

Methods

__construct

Constructor.

__construct(string name, \Joomla\Profiler\ProfilerRendererInterface renderer = null, \Joomla\Profiler\ProfilePointInterface[] points = [], bool memoryRealUsage = false) : mixed
since

1.0

throws

\InvalidArgumentException

Arguments

name

stringThe profiler name.

renderer

\Joomla\Profiler\ProfilerRendererInterfaceThe renderer.

points

\Joomla\Profiler\ProfilePointInterface[]An array of profile points.

memoryRealUsage

boolTrue to get the real memory usage.

Response

mixed

__toString

Cast the profiler to a string using the renderer.

__toString() : string
since

1.0

Response

stringThe rendered profiler.

count

Count the number of points in this profiler.

count() : int
since

1.0

Response

intThe number of points.

getIterator

Get an iterator on the profiler points.

getIterator() : \ArrayIterator
since

1.0

Response

\ArrayIteratorAn iterator on the profiler points.

getMemoryBytesBetween

Get the amount of allocated memory in bytes between the two points.

getMemoryBytesBetween(string first, string second) : int
since

1.0

throws

\LogicExceptionIf the points were not marked.

Arguments

first

stringThe name of the first point.

second

stringThe name of the second point.

Response

intThe amount of allocated memory between these points in bytes.

getMemoryPeakBytes

Get the memory peak in bytes during the profiler run.

getMemoryPeakBytes() : int
since

1.0

Response

intThe memory peak in bytes.

getName

Get the name of this profiler.

getName() : string
since

1.0

Response

stringThe name of this profiler.

getPoint

Get the point identified by the given name.

getPoint(string name, mixed default = null) : \Joomla\Profiler\ProfilePointInterface|mixed
since

1.0

Arguments

name

stringThe name of the point.

default

mixedThe default value if the point hasn't been marked.

Response

\Joomla\Profiler\ProfilePointInterface|mixedThe profile point or the default value.

getPoints

Get the points in this profiler (from the first to the last).

getPoints() : \Joomla\Profiler\ProfilePointInterface[]
since

1.0

Response

\Joomla\Profiler\ProfilePointInterface[]An array of points in this profiler.

getRenderer

Get the currently used renderer in this profiler.

getRenderer() : \Joomla\Profiler\ProfilerRendererInterface
since

1.0

Response

\Joomla\Profiler\ProfilerRendererInterfaceThe renderer.

getTimeBetween

Get the elapsed time in seconds between the two points.

getTimeBetween(string first, string second) : float
since

1.0

throws

\LogicExceptionIf the points were not marked.

Arguments

first

stringThe name of the first point.

second

stringThe name of the second point.

Response

floatThe elapsed time between these points in seconds.

hasPoint

Check if the profiler has marked the given point.

hasPoint(string name) : bool
since

1.0

Arguments

name

stringThe name of the point.

Response

boolTrue if the profiler has marked the point, false otherwise.

mark

Mark a profile point.

mark(string name) : \Joomla\Profiler\ProfilerInterface
since

1.0

throws

\InvalidArgumentExceptionIf the point already exists.

Arguments

name

stringThe profile point name.

Response

\Joomla\Profiler\ProfilerInterfaceThis method is chainable.

render

Render the profiler.

render() : string
since

1.0

Response

stringThe rendered profiler.

setPoints

Set the points in this profiler.

setPoints(\Joomla\Profiler\ProfilePointInterface[] points) : void

This function is called by the constructor when injecting an array of points (mostly for testing purposes).

since

1.0

throws

\InvalidArgumentException

Arguments

points

\Joomla\Profiler\ProfilePointInterface[]An array of profile points.

setRenderer

Set the renderer to render this profiler.

setRenderer(\Joomla\Profiler\ProfilerRendererInterface renderer) : \Joomla\Profiler\Profiler
since

1.0

Arguments

renderer

\Joomla\Profiler\ProfilerRendererInterfaceThe renderer.

Response

\Joomla\Profiler\ProfilerThis method is chainable.

setStart

Creates a profile point with the specified starting time and memory.

setStart(float timeStamp = 0.0, int memoryBytes) : \Joomla\Profiler\ProfilerInterface

This method will only add a point if no other points have been added as the ProfilePointInterface objects created before changing the start point would result in inaccurate measurements.

since

1.2.0

throws

\RuntimeException

Arguments

timeStamp

floatUnix timestamp in microseconds when the profiler should start measuring time.

memoryBytes

intMemory amount in bytes when the profiler should start measuring memory.

Response

\Joomla\Profiler\ProfilerInterfaceThis method is chainable.

Properties

name

The name of the profiler.

since

1.0

Type(s)

string

points

An array of profiler points (from the first to last).

since

1.0

Type(s)

\Joomla\Profiler\ProfilePointInterface[]

lookup

A lookup array containing the names of the already marked points as keys * and their indexes in $points as value.

It is used to quickly find a point without having to traverse $points.

since

1.0

Type(s)

array

memoryRealUsage

A flag to see if we must get the real memory usage, or the usage of emalloc().

since

1.0

Type(s)

bool

startTimeStamp

The timestamp with microseconds when the first point was marked.

since

1.0

Type(s)

float

startMemoryBytes

The memory usage in bytes when the first point was marked.

since

1.0

Type(s)

int

memoryPeakBytes

The memory peak in bytes during the profiler run.

since

1.0

Type(s)

int

renderer

The profiler renderer.

since

1.0

Type(s)

\Joomla\Profiler\ProfilerRendererInterface