class ExcimerLog implements ArrayAccess, Iterator (View source)

A collected series of stack traces and some utility methods to aggregate them.

ExcimerLog acts as a container for ExcimerLogEntry objects. The Iterator or ArrayAccess interfaces may be used to access them. For example:

foreach ($profiler->getLog() as $entry) { var_dump($entry->getTrace()); }

Methods

string
formatCollapsed()

Aggregate the stack traces and convert them to a line-based format understood by Brendan Gregg's FlameGraph utility. Each stack trace is represented as a series of function names, separated by semicolons.

array
aggregateByFunction()

Produce an array with an element for every function which appears in the log. The key is a human-readable unique identifier for the function, method or closure. The value is an associative array with the following elements:

array
getSpeedscopeData()

Get an array which can be JSON encoded for import into speedscope

int
getEventCount()

Get the total number of profiling periods represented by this log.

mixed
current()

Get the current ExcimerLogEntry object. Part of the Iterator interface.

mixed
key()

Get the current integer key or null. Part of the Iterator interface.

void
next()

Advance to the next log entry. Part of the Iterator interface.

void
rewind()

Rewind back to the first log entry. Part of the Iterator interface.

bool
valid()

Check if the current position is valid. Part of the Iterator interface.

int
count()

Get the number of log entries contained in this log. This is always less than or equal to the number returned by getEventCount(), which includes overruns.

bool
offsetExists(TKey $offset)

Determine whether a log entry exists at the specified array offset.

mixed
offsetGet(TKey $offset)

Get the ExcimerLogEntry object at the specified array offset.

void
offsetSet(TKey $offset, TValue $value)

This function is included for compliance with the ArrayAccess interface.

void
offsetUnset(TKey $offset)

This function is included for compliance with the ArrayAccess interface.

Details

string formatCollapsed()

Aggregate the stack traces and convert them to a line-based format understood by Brendan Gregg's FlameGraph utility. Each stack trace is represented as a series of function names, separated by semicolons.

After this identifier, there is a single space character, then a number giving the number of times the stack appeared. Then there is a line break. This is repeated for each unique stack trace.

Return Value

string

array aggregateByFunction()

Produce an array with an element for every function which appears in the log. The key is a human-readable unique identifier for the function, method or closure. The value is an associative array with the following elements:

  • self: The number of events in which the function itself was running, no other userspace function was being called. This includes time spent in internal functions that this function called.
    • inclusive: The number of events in which this function appeared somewhere in the stack.

And optionally the following elements, if they are relevant:

  • file: The filename in which the function appears
  • line: The exact line number at which the first relevant event occurred.
  • class: The class name in which the method is defined
  • function: The name of the function or method
  • closure_line: The line number at which the closure was defined

The event counts in the "self" and "inclusive" fields are adjusted for overruns. They represent an estimate of the number of profiling periods in which those functions were present.

Return Value

array

array getSpeedscopeData()

Get an array which can be JSON encoded for import into speedscope

Return Value

array

int getEventCount()

Get the total number of profiling periods represented by this log.

Return Value

int

mixed current()

Get the current ExcimerLogEntry object. Part of the Iterator interface.

Return Value

mixed

Can return any type.

mixed key()

Get the current integer key or null. Part of the Iterator interface.

Return Value

mixed

TKey on success, or null on failure.

void next()

Advance to the next log entry. Part of the Iterator interface.

Return Value

void

Any returned value is ignored.

void rewind()

Rewind back to the first log entry. Part of the Iterator interface.

Return Value

void

Any returned value is ignored.

bool valid()

Check if the current position is valid. Part of the Iterator interface.

Return Value

bool

The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.

int count()

Get the number of log entries contained in this log. This is always less than or equal to the number returned by getEventCount(), which includes overruns.

Return Value

int

bool offsetExists(TKey $offset)

Determine whether a log entry exists at the specified array offset.

Part of the ArrayAccess interface.

Parameters

TKey $offset

An offset to check for.

Return Value

bool

true on success or false on failure.

The return value will be casted to boolean if non-boolean was returned.

mixed offsetGet(TKey $offset)

Get the ExcimerLogEntry object at the specified array offset.

Parameters

TKey $offset

The offset to retrieve.

Return Value

mixed

Can return all value types.

void offsetSet(TKey $offset, TValue $value)

This function is included for compliance with the ArrayAccess interface.

It raises a warning and does nothing.

Parameters

TKey $offset

The offset to assign the value to.

TValue $value

The value to set.

Return Value

void

void offsetUnset(TKey $offset)

This function is included for compliance with the ArrayAccess interface.

It raises a warning and does nothing.

Parameters

TKey $offset

The offset to unset.

Return Value

void