You are here

function xhprof_trim_run in XHProf 7

Same name and namespace in other branches
  1. 6 xhprof.inc \xhprof_trim_run()

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

Parameters

array XHProf raw data:

array array of function names:

Return value

array Trimmed XHProf Report

1 call to xhprof_trim_run()
xhprof_profiler_report in ./xhprof.inc
Analyze raw data & generate the profiler report (common for both single run mode and diff mode).

File

./xhprof.inc, line 1481

Code

function xhprof_trim_run($raw_data, $functions_to_keep) {

  // convert list of functions to a hash with function as the key
  $function_map = array_fill_keys($functions_to_keep, 1);

  // always keep main() as well so that overall totals can still
  // be computed if need be.
  $function_map['main()'] = 1;
  $new_raw_data = array();
  foreach ($raw_data as $parent_child => $info) {
    list($parent, $child) = xhprof_parse_parent_child($parent_child);
    if (isset($function_map[$parent]) || isset($function_map[$child])) {
      $new_raw_data[$parent_child] = $info;
    }
  }
  return $new_raw_data;
}