include/SugarXHprof/xhprof_lib/utils/xhprof_lib.php

Show: inherited
Table of Contents

Constants

Constant  XHPROF_STRING_PARAM = 1

Type definitions for URL params

Constant  XHPROF_UINT_PARAM = 2
Constant  XHPROF_FLOAT_PARAM = 3
Constant  XHPROF_BOOL_PARAM = 4

Functions

functioninit_metrics(  $xhprof_data,  $rep_symbol,  $sort,  $diff_report = false ) : void

Initialize the metrics we'll display based on the information in the raw data.

Parameters
Name Type Description
$xhprof_data
$rep_symbol
$sort
$diff_report
Details
Author
Kannan  
functionxhprof_aggregate_runs( object $xhprof_runs_impl, array $runs, array $wts, string $source = "phprof", bool $use_script_name = false ) : array

Get raw data corresponding to specified array of runs aggregated by certain weightage.

Suppose you have run:5 corresponding to page1.php, run:6 corresponding to page2.php, and run:7 corresponding to page3.php

and you want to accumulate these runs in a 2:4:1 ratio. You can do so by calling:

xhprof_aggregate_runs(array(5, 6, 7), array(2, 4, 1));

The above will return raw data for the runs aggregated in 2:4:1 ratio.

Parameters
Name Type Description
$xhprof_runs_impl object

An object that implements the iXHProfRuns interface

$runs array

run ids of the XHProf runs..

$wts array

integral (ideally) weights for $runs

$source string

source to fetch raw data for run from

$use_script_name bool

If true, a fake edge from main() to to __script:: is introduced in the raw data so that after aggregations the script name is still preserved.

Returns
Type Description
array Return aggregated raw data
Details
Author
Kannan  
functionxhprof_array_set(  $arr,  $k,  $v ) : void

Set one key in an array and return the array

Parameters
Name Type Description
$arr
$k
$v
Details
Author
Kannan  
functionxhprof_array_unset(  $arr,  $k ) : void

Removes/unsets one key in an array and return the array

Parameters
Name Type Description
$arr
$k
Details
Author
Kannan  
functionxhprof_build_parent_child_key(  $parent,  $child ) : void

Given parent & child function name, composes the key in the format present in the raw data.

Parameters
Name Type Description
$parent
$child
Details
Author
Kannan  
functionxhprof_compute_diff(  $xhprof_data1,  $xhprof_data2 ) : void

Hierarchical diff: Compute and return difference of two call graphs: Run2 - Run1.

Parameters
Name Type Description
$xhprof_data1
$xhprof_data2
Details
Author
Kannan  
functionxhprof_compute_flat_info( array $raw_data, array $overall_totals ) : array

Analyze hierarchical raw data, and compute per-function (flat) inclusive and exclusive metrics.

Also, store overall totals in the 2nd argument.

Parameters
Name Type Description
$raw_data array

XHProf format raw profiler data.

$overall_totals array

&$overall_totals OUT argument for returning overall totals for various metrics.

Returns
Type Description
array Returns a map from function name to its call count and inclusive & exclusive metrics (such as wall time, etc.).
Details
Author
Kannan Muthukkaruppan  
functionxhprof_compute_inclusive_times(  $raw_data ) : array

Compute inclusive metrics for function. This code was factored out of xhprof_compute_flat_info().

The raw data contains inclusive metrics of a function for each unique parent function it is called from. The total inclusive metrics for a function is therefore the sum of inclusive metrics for the function across all parents.

Parameters
Name Type Description
$raw_data
Returns
Type Description
array Returns a map of function name to total (across all parents) inclusive metrics for the function.
Details
Author
Kannan  
functionxhprof_error(  $message ) : void

Parameters
Name Type Description
$message
functionxhprof_get_bool_param(  $param,  $default = false ) : void

Extracts value for a boolean param $param from query string. If param is not specified, return the $default value.

If value is not a valid unsigned integer, logs error and returns null.

Parameters
Name Type Description
$param
$default
Details
Author
Kannan  
functionxhprof_get_float_param(  $param,  $default = 0 ) : void

Extracts value for a float param $param from query string. If param is not specified, return the $default value.

If value is not a valid unsigned integer, logs error and returns null.

Parameters
Name Type Description
$param
$default
Details
Author
Kannan  
functionxhprof_get_matching_functions(  $q,  $xhprof_data ) : void

Given a partial query string $q return matching function names in specified XHProf run. This is used for the type ahead function selector.

Parameters
Name Type Description
$q
$xhprof_data
Details
Author
Kannan  
functionxhprof_get_metrics(  $xhprof_data ) : void

Parameters
Name Type Description
$xhprof_data
functionxhprof_get_param_helper( string $param ) : void

Internal helper function used by various xhprof_get_param* flavors for various types of parameters.

Parameters
Name Type Description
$param string

name of the URL query string param

Details
Author
Kannan  
functionxhprof_get_possible_metrics( ) : void

functionxhprof_get_string_param(  $param,  $default = '' ) : void

Extracts value for string param $param from query string. If param is not specified, return the $default value.

Parameters
Name Type Description
$param
$default
Details
Author
Kannan  
functionxhprof_get_uint_param(  $param,  $default = 0 ) : void

Extracts value for unsigned integer param $param from query string. If param is not specified, return the $default value.

If value is not a valid unsigned integer, logs error and returns null.

Parameters
Name Type Description
$param
$default
Details
Author
Kannan  
functionxhprof_normalize_metrics(  $raw_data,  $num_runs ) : void

Takes raw XHProf data that was aggregated over "$num_runs" number of runs averages/nomalizes the data. Essentially the various metrics collected are divided by $num_runs.

Parameters
Name Type Description
$raw_data
$num_runs
Details
Author
Kannan  
functionxhprof_param_init(  $params ) : void

Initialize params from URL query string. The function creates globals variables for each of the params and if the URL query string doesn't specify a particular param initializes them with the corresponding default value specified in the input.

Parameters
Name Type Description
$params
Details
Author
Kannan  
Params
array $params An array whose keys are the names of URL params who value needs to be retrieved from the URL query string. PHP globals are created with these names. The value is itself an array with 2-elems (the param type, and its default value). If a param is not specified in the query string the default value is used.  
functionxhprof_parse_parent_child(  $parent_child ) : void

Takes a parent/child function name encoded as "a==>b" and returns array("a", "b").

Parameters
Name Type Description
$parent_child
Details
Author
Kannan  
functionxhprof_prune_run(  $raw_data,  $prune_percent ) : void

Parameters
Name Type Description
$raw_data
$prune_percent
functionxhprof_trim_run( array $raw_data, array $functions_to_keep ) : array

Return a trimmed version of the XHProf raw data. Note that the raw data contains one entry for each unique parent/child function combination.The trimmed version of raw data will only contain entries where either the parent or child function is in the list of $functions_to_keep.

Note: Function main() is also always kept so that overall totals can still be obtained from the trimmed version.

Parameters
Name Type Description
$raw_data array

XHProf raw data

$functions_to_keep array

array of function names

Returns
Type Description
array Trimmed XHProf Report
Details
Author
Kannan  
functionxhprof_valid_run(  $run_id, array $raw_data ) : bool

Checks if XHProf raw data appears to be valid and not corrupted.

@param int $run_id Run id of run to be pruned. [Used only for reporting errors.]

Parameters
Name Type Description
$run_id
$raw_data array

XHProf raw data to be pruned /p>

Returns
Type Description
bool true on success, false on failure
Details
Author
Kannan  
Documentation was generated by DocBlox 0.18.1.