include/SugarXHprof/xhprof_lib/utils/xhprof_lib.php
Constants
Functions
init_metrics(
$xhprof_data, $rep_symbol, $sort, $diff_report
=
false
)
:
voidInitialize the metrics we'll display based on the information in the raw data.
| Name | Type | Description |
|---|---|---|
| $xhprof_data | ||
| $rep_symbol | ||
| $sort | ||
| $diff_report |
- Author
- Kannan
xhprof_aggregate_runs(
object $xhprof_runs_impl, array $runs, array $wts, string $source
=
"phprof", bool $use_script_name
=
false
)
:
arrayGet 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.
| 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:: |
| Type | Description |
|---|---|
| array | Return aggregated raw data |
- Author
- Kannan
xhprof_array_set(
$arr, $k, $v
)
:
voidSet one key in an array and return the array
| Name | Type | Description |
|---|---|---|
| $arr | ||
| $k | ||
| $v |
- Author
- Kannan
xhprof_array_unset(
$arr, $k
)
:
voidRemoves/unsets one key in an array and return the array
| Name | Type | Description |
|---|---|---|
| $arr | ||
| $k |
- Author
- Kannan
xhprof_build_parent_child_key(
$parent, $child
)
:
voidGiven parent & child function name, composes the key in the format present in the raw data.
| Name | Type | Description |
|---|---|---|
| $parent | ||
| $child |
- Author
- Kannan
xhprof_compute_diff(
$xhprof_data1, $xhprof_data2
)
:
voidHierarchical diff: Compute and return difference of two call graphs: Run2 - Run1.
| Name | Type | Description |
|---|---|---|
| $xhprof_data1 | ||
| $xhprof_data2 |
- Author
- Kannan
xhprof_compute_flat_info(
array $raw_data, array $overall_totals
)
:
arrayAnalyze hierarchical raw data, and compute per-function (flat) inclusive and exclusive metrics.
Also, store overall totals in the 2nd argument.
| 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. |
| Type | Description |
|---|---|
| array | Returns a map from function name to its call count and inclusive & exclusive metrics (such as wall time, etc.). |
- Author
- Kannan Muthukkaruppan
xhprof_compute_inclusive_times(
$raw_data
)
:
arrayCompute 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.
| Name | Type | Description |
|---|---|---|
| $raw_data |
| Type | Description |
|---|---|
| array | Returns a map of function name to total (across all parents) inclusive metrics for the function. |
- Author
- Kannan
xhprof_get_bool_param(
$param, $default
=
false
)
:
voidExtracts 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.
| Name | Type | Description |
|---|---|---|
| $param | ||
| $default |
- Author
- Kannan
xhprof_get_float_param(
$param, $default
=
0
)
:
voidExtracts 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.
| Name | Type | Description |
|---|---|---|
| $param | ||
| $default |
- Author
- Kannan
xhprof_get_matching_functions(
$q, $xhprof_data
)
:
voidGiven a partial query string $q return matching function names in specified XHProf run. This is used for the type ahead function selector.
| Name | Type | Description |
|---|---|---|
| $q | ||
| $xhprof_data |
- Author
- Kannan
xhprof_get_param_helper(
string $param
)
:
voidInternal helper function used by various xhprof_get_param* flavors for various types of parameters.
| Name | Type | Description |
|---|---|---|
| $param | string | name of the URL query string param |
- Author
- Kannan
xhprof_get_string_param(
$param, $default
=
''
)
:
voidExtracts value for string param $param from query string. If param is not specified, return the $default value.
| Name | Type | Description |
|---|---|---|
| $param | ||
| $default |
- Author
- Kannan
xhprof_get_uint_param(
$param, $default
=
0
)
:
voidExtracts 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.
| Name | Type | Description |
|---|---|---|
| $param | ||
| $default |
- Author
- Kannan
xhprof_normalize_metrics(
$raw_data, $num_runs
)
:
voidTakes 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.
| Name | Type | Description |
|---|---|---|
| $raw_data | ||
| $num_runs |
- Author
- Kannan
xhprof_param_init(
$params
)
:
voidInitialize 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.
| Name | Type | Description |
|---|---|---|
| $params |
- 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.
xhprof_parse_parent_child(
$parent_child
)
:
voidTakes a parent/child function name encoded as "a==>b" and returns array("a", "b").
| Name | Type | Description |
|---|---|---|
| $parent_child |
- Author
- Kannan
xhprof_prune_run(
$raw_data, $prune_percent
)
:
void| Name | Type | Description |
|---|---|---|
| $raw_data | ||
| $prune_percent |
xhprof_trim_run(
array $raw_data, array $functions_to_keep
)
:
arrayReturn 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.
| Name | Type | Description |
|---|---|---|
| $raw_data | array | XHProf raw data |
| $functions_to_keep | array | array of function names |
| Type | Description |
|---|---|
| array | Trimmed XHProf Report |
- Author
- Kannan
xhprof_valid_run(
$run_id, array $raw_data
)
:
boolChecks 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.]
| Name | Type | Description |
|---|---|---|
| $run_id | ||
| $raw_data | array | XHProf raw data to be pruned /p> |
| Type | Description |
|---|---|
| bool | true on success, false on failure |
- Author
- Kannan