PHP Class Xhgui_Profile, xhgui

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

Protected Properties

Свойство Type Description
$_collapsed
$_data
$_exclusiveKeys
$_functionCount
$_indexed
$_keys
$_visited

Méthodes publiques

Méthode 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 ( )

Méthodes protégées

Méthode 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 méthode

public __construct ( $profile, $convert = true )

_callgraphData() protected méthode

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

_diffKeys() protected méthode

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

_diffPercentKeys() protected méthode

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

_flamegraphData() protected méthode

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

_getChildren() protected méthode

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
Résultat array An array of child methods.

_getParents() protected méthode

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.
Résultat array List of parents

_maxValue() protected méthode

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

_process() protected méthode

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
Résultat void

_sumKeys() protected méthode

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.
Résultat array Merged profile data.

calculateSelf() public méthode

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
Résultat Xhgui_Profile A new instance with exclusive data set.

compare() public méthode

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

extractDimension() public méthode

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
Résultat array Array of data with name = function name and value = the dimension.

get() public méthode

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.
Résultat null | float

getCallgraph() public méthode

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
Résultat array

getDate() public méthode

public getDate ( )

getFlamegraph() public méthode

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
Résultat array

getFunctionCount() public méthode

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

getId() public méthode

public getId ( )

getMeta() public méthode

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.
Résultat null | mixed Null on failure, otherwise the stored value.

getProfile() public méthode

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

getRelatives() public méthode

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.
Résultat array List of (parent, current, children)

getWatched() public méthode

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

sort() public méthode

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.
Résultat array The sorted data.

splitName() public méthode

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

toArray() public méthode

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