function xhprof_display_run in XHProf 6
Same name and namespace in other branches
- 7 xhprof.module \xhprof_display_run()
Display XHProf run report.
2 calls to xhprof_display_run()
- xhprof_display_diff_page in ./
xhprof.module - Page callback to display a difference of two XHProf runs.
- xhprof_display_page in ./
xhprof.module - Page callback to display a XHProf run.
File
- ./
xhprof.module, line 307
Code
function xhprof_display_run($run_ids, $symbol = NULL) {
if (count($run_ids) === 1) {
$_GET['run'] = $run_ids[0];
$run_id = $run_ids[0];
}
else {
$_GET['run1'] = $run_ids[0];
$run1 = $run_ids[0];
$_GET['run2'] = $run_ids[1];
$run2 = $run_ids[1];
}
$source = variable_get('site_name', '');
$_GET['source'] = $source;
$url_params = xhprof_param_defaults();
$required_params = array(
'sort',
);
foreach ($url_params as $param => &$value) {
if (isset($_GET[$param])) {
$value = $_GET[$param];
}
elseif (!in_array($param, $required_params)) {
unset($url_params[$param]);
}
}
// Extract params here instead of making them globals. Gross, I know, but
// less gross than this was originally. Should make this less dumb in the
// future.
extract($url_params);
$class = variable_get('xhprof_default_class', 'XHProfRunsFile');
$xhprof_runs_impl = new $class();
$output = '';
if (isset($run_id)) {
// run may be a single run or a comma separate list of runs
// that'll be aggregated. If "wts" (a comma separated list
// of integral weights is specified), the runs will be
// aggregated in that ratio.
$runs_array = explode(",", $run_id);
if (isset($_GET['order'])) {
$sort = xhprof_stat_description($_GET['order'], TRUE);
}
if (count($runs_array) == 1) {
$xhprof_data = $xhprof_runs_impl
->get_run($runs_array[0], $source, $description, $sort);
}
else {
if (!empty($wts)) {
$wts_array = explode(",", $wts);
}
else {
$wts_array = NULL;
}
$data = xhprof_aggregate_runs($xhprof_runs_impl, $runs_array, $wts_array, $source, FALSE);
$xhprof_data = $data['raw'];
$description = $data['description'];
}
xhprof_init_metrics($xhprof_data, $symbol, $sort, FALSE);
$output .= xhprof_profiler_report($url_params, $symbol, $sort, $run_id, $description, $xhprof_data);
}
elseif ($run1 && $run2) {
// Diff report for two runs.
$xhprof_data1 = $xhprof_runs_impl
->get_run($run1, $source, $description1);
$xhprof_data2 = $xhprof_runs_impl
->get_run($run2, $source, $description2);
// Initialize what metrics we'll display based on data in Run2
$output .= xhprof_init_metrics($xhprof_data2, $symbol, $sort, TRUE);
$output .= xhprof_profiler_report($url_params, $symbol, $sort, $run1, $description1, $xhprof_data1, $run2, $description2, $xhprof_data2);
}
else {
$output .= "No XHProf runs specified in the URL.";
}
return $output;
}