Since: 1.7.0

class Profiler

Utility class to assist in the process of benchmarking the execution of sections of code to understand where time is being spent.

Properties

protected int Since: 3.0.0
$start
protected string Since: 3.0.0
$prefix
protected array Since: 3.0.0
$buffer
protected array Since: 3.0.0
$marks
protected float Since: 3.0.0
$previousTime
protected float Since: 3.0.0
$previousMem
static protected array Since: 1.7.3
$instances

Methods

__construct(string $prefix = '')

Constructor

static Profiler
getInstance(string $prefix = '')

Returns the global Profiler object, only creating it if it doesn't already exist.

string
mark(string $label)

Output a time mark

array
getMarks()

Get all profiler marks.

array
getBuffer()

Get all profiler mark buffers.

$this
setStart(float $startTime = 0.0, int $startMem = 0)

Sets the start time.

Details

__construct(string $prefix = '')

Since: 1.7.0

Constructor

Parameters

string $prefix

Prefix for mark messages

static Profiler getInstance(string $prefix = '')

Since: 1.7.0

Returns the global Profiler object, only creating it if it doesn't already exist.

Parameters

string $prefix

Prefix used to distinguish profiler objects.

Return Value

Profiler

The Profiler object.

string mark(string $label)

Since: 1.7.0

Output a time mark

Parameters

string $label

A label for the time mark

Return Value

string

array getMarks()

Since: 1.7.0

Get all profiler marks.

Returns an array of all marks created since the Profiler object was instantiated. Marks are objects as per JProfiler::mark().

Return Value

array

Array of profiler marks

array getBuffer()

Since: 1.7.0

Get all profiler mark buffers.

Returns an array of all mark buffers created since the Profiler object was instantiated. Marks are strings as per Profiler::mark().

Return Value

array

Array of profiler marks

$this setStart(float $startTime = 0.0, int $startMem = 0)

Since: 3.0.0

Sets the start time.

Parameters

float $startTime

Unix timestamp in microseconds for setting the Profiler start time.

int $startMem

Memory amount in bytes for setting the Profiler start memory.

Return Value

$this

For chaining