Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Functions that are not part of a class:

xhprof_error($message)   X-Ref
No description

xhprof_get_possible_metrics()   X-Ref
No description

init_metrics($xhprof_data, $rep_symbol, $sort, $diff_report = false)   X-Ref
Initialize the metrics we'll display based on the information
in the raw data.

author: Kannan

xhprof_get_metrics($xhprof_data)   X-Ref
No description

xhprof_parse_parent_child($parent_child)   X-Ref
Takes a parent/child function name encoded as
"a==>b" and returns array("a", "b").

author: Kannan

xhprof_build_parent_child_key($parent, $child)   X-Ref
Given parent & child function name, composes the key
in the format present in the raw data.

author: Kannan

xhprof_valid_run($run_id, $raw_data)   X-Ref
Checks if XHProf raw data appears to be valid and not corrupted.

author: Kannan
return: bool   true on success, false on failure
param: int    $run_id        Run id of run to be pruned.
param: array  $raw_data      XHProf raw data to be pruned

xhprof_trim_run($raw_data, $functions_to_keep)   X-Ref
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.

author: Kannan
return: array  Trimmed XHProf Report
param: array  XHProf raw data
param: array  array of function names

xhprof_normalize_metrics($raw_data, $num_runs)   X-Ref
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.

author: Kannan

xhprof_aggregate_runs($xhprof_runs_impl, $runs,$wts, $source="phprof",$use_script_name=false)   X-Ref
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.

author: Kannan
return: array  Return aggregated raw data
param: object  $xhprof_runs_impl  An object that implements
param: array  $runs            run ids of the XHProf runs..
param: array  $wts             integral (ideally) weights for $runs
param: string $source          source to fetch raw data for run from
param: bool   $use_script_name If true, a fake edge from main() to

xhprof_compute_flat_info($raw_data, &$overall_totals)   X-Ref
Analyze hierarchical raw data, and compute per-function (flat)
inclusive and exclusive metrics.

Also, store overall totals in the 2nd argument.

author: Kannan Muthukkaruppan
return: array Returns a map from function name to its
param: array $raw_data          XHProf format raw profiler data.
param: array &$overall_totals   OUT argument for returning

xhprof_compute_diff($xhprof_data1, $xhprof_data2)   X-Ref
Hierarchical diff:
Compute and return difference of two call graphs: Run2 - Run1.

author: Kannan

xhprof_compute_inclusive_times($raw_data)   X-Ref
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.

author: Kannan
return: array  Returns a map of function name to total (across all parents)

xhprof_prune_run($raw_data, $prune_percent)   X-Ref
No description

xhprof_array_set($arr, $k, $v)   X-Ref
Set one key in an array and return the array

author: Kannan

xhprof_array_unset($arr, $k)   X-Ref
Removes/unsets one key in an array and return the array

author: Kannan

xhprof_get_param_helper($param)   X-Ref
Internal helper function used by various
xhprof_get_param* flavors for various
types of parameters.

author: Kannan
param: string   name of the URL query string param

xhprof_get_string_param($param, $default = '')   X-Ref
Extracts value for string param $param from query
string. If param is not specified, return the
$default value.

author: Kannan

xhprof_get_uint_param($param, $default = 0)   X-Ref
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.

author: Kannan

xhprof_get_float_param($param, $default = 0)   X-Ref
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.

author: Kannan

xhprof_get_bool_param($param, $default = false)   X-Ref
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.

author: Kannan

xhprof_param_init($params)   X-Ref
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.

author: Kannan

xhprof_get_matching_functions($q, $xhprof_data)   X-Ref
Given a partial query string $q return matching function names in
specified XHProf run. This is used for the type ahead function
selector.

author: Kannan