PHP Class Xhgui_Profile, xhgui

Provides method to manipulate the data from a single profile run.
Exibir arquivo Open project: perftools/xhgui Class Usage Examples

Protected Properties

Property Type Description
$_collapsed
$_data
$_exclusiveKeys
$_functionCount
$_indexed
$_keys
$_visited

Public Methods

Method Description
__construct ( $profile, $convert = true )
calculateSelf ( ) : Xhgui_Profile Generate the approximate exclusive values for each metric.
compare ( Xhgui_Profile $head ) : array Compare this run to another run.
extractDimension ( string $dimension, integer $limit ) : array Extracts a single dimension of data from a profile run.
get ( string $key, string $metric = null ) : null | float Read data from the profile run.
getCallgraph ( $metric = 'wt', $threshold = 0.01 ) : array Return a structured array suitable for generating callgraph visualizations.
getDate ( )
getFlamegraph ( $metric = 'wt', $threshold = 0.01 ) : array Return a structured array suitable for generating flamegraph visualizations.
getFunctionCount ( ) : integer Get the total number of tracked function calls in this run.
getId ( )
getMeta ( string $key = null ) : null | mixed Get meta data about the profile. Read's a . split path out of the meta data in a profile. For example SERVER.REQUEST_TIME
getProfile ( ) : array Get the profile run data.
getRelatives ( string $symbol, string $metric = null, float $threshold ) : array Find the parent and children method/functions for a given symbol.
getWatched ( string $pattern ) : null | array Find a function matching a watched function.
sort ( string $dimension, array $data ) : array Sort data by a dimension.
splitName ( string $name ) : array Split a key name into the parent==>child format.
toArray ( )

Protected Methods

Method Description
_callgraphData ( $parentName, $main, $metric, $threshold, $parentIndex = null )
_diffKeys ( $a, $b, $includeSelf = true )
_diffPercentKeys ( $a, $b, $includeSelf = true )
_flamegraphData ( $parentName, $main, $metric, $threshold, $parentIndex = null )
_getChildren ( string $symbol, string $metric = null, float $threshold ) : array Find symbols that are the children of the given name.
_getParents ( string $symbol ) : array Get the parent methods for a given symbol.
_maxValue ( string $metric ) Get the max value for any give metric.
_process ( ) : void Convert the raw data into a flatter list that is easier to use.
_sumKeys ( array $a, array $b ) : array Sum up the values in $this->_keys;

Method Details

__construct() public method

public __construct ( $profile, $convert = true )

_callgraphData() protected method

protected _callgraphData ( $parentName, $main, $metric, $threshold, $parentIndex = null )

_diffKeys() protected method

protected _diffKeys ( $a, $b, $includeSelf = true )

_diffPercentKeys() protected method

protected _diffPercentKeys ( $a, $b, $includeSelf = true )

_flamegraphData() protected method

protected _flamegraphData ( $parentName, $main, $metric, $threshold, $parentIndex = null )

_getChildren() protected method

Find symbols that are the children of the given name.
protected _getChildren ( string $symbol, string $metric = null, float $threshold ) : array
$symbol string The name of the function to find children of.
$metric string The metric to compare $threshold with.
$threshold float The threshold to exclude functions at. Any function that represents less than
return array An array of child methods.

_getParents() protected method

Get the parent methods for a given symbol.
protected _getParents ( string $symbol ) : array
$symbol string The name of the function/method to find parents for.
return array List of parents

_maxValue() protected method

Get the max value for any give metric.
protected _maxValue ( string $metric )
$metric string The metric to get a max value for.

_process() protected method

This removes some of the parentage detail as all calls of a given method are aggregated. We are not able to maintain a full tree structure in any case, as xhprof only keeps one level of detail.
protected _process ( ) : void
return void

_sumKeys() protected method

Sum up the values in $this->_keys;
protected _sumKeys ( array $a, array $b ) : array
$a array The first set of profile data
$b array The second set of profile data.
return array Merged profile data.

calculateSelf() public method

We get a==>b as the name, we need a key for a and b in the array to get exclusive values for A we need to subtract the values of B (and any other children); call passing in the entire profile only, should return an array of functions with their regular timing, and exclusive numbers inside ['exclusive'] Consider: ---c---d---e a -/----b---d---e We have c==>d and b==>d, and in both instances d invokes e, yet we will have but a single d==>e result. This is a known and documented limitation of XHProf We have one d==>e entry, with some values, including ct=2 We also have c==>d and b==>d We should determine how many ==>d options there are, and equally split the cost of d==>e across them since d==>e represents the sum total of all calls. Notes: Function names are not unique, but we're merging them
public calculateSelf ( ) : Xhgui_Profile
return Xhgui_Profile A new instance with exclusive data set.

compare() public method

Compare this run to another run.
public compare ( Xhgui_Profile $head ) : array
$head Xhgui_Profile The other run to compare with
return array An array of comparison data.

extractDimension() public method

Useful for creating bar/column graphs. The profile data will be sorted by the column and then the $limit records will be extracted.
public extractDimension ( string $dimension, integer $limit ) : array
$dimension string The dimension to extract
$limit integer Number of elements to pull
return array Array of data with name = function name and value = the dimension.

get() public method

Read data from the profile run.
public get ( string $key, string $metric = null ) : null | float
$key string The function key name to read.
$metric string The metric to read.
return null | float

getCallgraph() public method

Functions whose inclusive time is less than 2% of the total time will be excluded from the callgraph data.
public getCallgraph ( $metric = 'wt', $threshold = 0.01 ) : array
return array

getDate() public method

public getDate ( )

getFlamegraph() public method

Functions whose inclusive time is less than 1% of the total time will be excluded from the callgraph data.
public getFlamegraph ( $metric = 'wt', $threshold = 0.01 ) : array
return array

getFunctionCount() public method

Get the total number of tracked function calls in this run.
public getFunctionCount ( ) : integer
return integer

getId() public method

public getId ( )

getMeta() public method

Get meta data about the profile. Read's a . split path out of the meta data in a profile. For example SERVER.REQUEST_TIME
public getMeta ( string $key = null ) : null | mixed
$key string The dotted key to read.
return null | mixed Null on failure, otherwise the stored value.

getProfile() public method

TODO remove this and move all the features using it into this/ other classes.
public getProfile ( ) : array
return array

getRelatives() public method

The parent/children arrays will contain all the callers + callees of the symbol given. The current index will give the total inclusive values for all properties.
public getRelatives ( string $symbol, string $metric = null, float $threshold ) : array
$symbol string The name of the function/method to find relatives for.
$metric string The metric to compare $threshold with.
$threshold float The threshold to exclude child functions at. Any function that represents less than this percentage of the current metric will be filtered out.
return array List of (parent, current, children)

getWatched() public method

Find a function matching a watched function.
public getWatched ( string $pattern ) : null | array
$pattern string The pattern to look for.
return null | array An list of matching functions or null.

sort() public method

Sort data by a dimension.
public sort ( string $dimension, array $data ) : array
$dimension string The dimension to sort by.
$data array The data to sort.
return array The sorted data.

splitName() public method

Split a key name into the parent==>child format.
public splitName ( string $name ) : array
$name string The name to split.
return array An array of parent, child. parent will be null if there is no parent.

toArray() public method

public toArray ( )

Property Details

$_collapsed protected_oe property

protected $_collapsed

$_data protected_oe property

protected $_data

$_exclusiveKeys protected_oe property

protected $_exclusiveKeys

$_functionCount protected_oe property

protected $_functionCount

$_indexed protected_oe property

protected $_indexed

$_keys protected_oe property

protected $_keys

$_visited protected_oe property

protected $_visited