class Profiler

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

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

static  float
getmicrotime()

Get the current time.

integer
getMemory()

Get information about current memory usage.

array
getMarks()

Get all profiler marks.

array
getBuffer()

Get all profiler mark buffers.

$this
setStart( double $startTime, int $startMem)

Sets the start time.

Details

__construct( string $prefix = '')

Constructor

Parameters

string $prefix Prefix for mark messages

static Profiler getInstance( string $prefix = '')

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)

Output a time mark

Parameters

string $label A label for the time mark

Return Value

string

static float getmicrotime()

Get the current time.

Return Value

float The current time

integer getMemory()

Get information about current memory usage.

Return Value

integer The memory usage

array getMarks()

Get all profiler marks.

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

Return Value

array Array of profiler marks

array getBuffer()

Get all profiler mark buffers.

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

Return Value

array Array of profiler marks

$this setStart( double $startTime, int $startMem)

Sets the start time.

Parameters

double $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