function xhprof_full_report in XHProf 7
Same name and namespace in other branches
- 6 xhprof.inc \xhprof_full_report()
Generates a tabular report for all functions. This is the top-level report.
@author Kannan
1 call to xhprof_full_report()
- 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 869
Code
function xhprof_full_report($url_params, $symbol_tab, $sort, $run1, $run2) {
global $vwbar;
global $vbar;
global $totals;
global $totals_1;
global $totals_2;
global $metrics;
global $diff_mode;
global $descriptions;
global $sort_col;
global $format_cbk;
global $display_calls;
global $base_path;
global $stats;
$possible_metrics = xhprof_get_possible_metrics();
$output = '';
if ($diff_mode) {
$base_url_params = xhprof_array_unset(xhprof_array_unset($url_params, 'run1'), 'run2');
$href1 = "{$base_path}/?" . http_build_query(xhprof_array_set($base_url_params, 'run', $run1));
$href2 = "{$base_path}/?" . http_build_query(xhprof_array_set($base_url_params, 'run', $run2));
$output .= "<h3><center>Overall Diff Summary</center></h3>";
///$output .= '<table border=1 cellpadding=2 cellspacing=1 width="30%" ' .'rules=rows bordercolor="#bdc7d8" align=center>' . "\n";
//$output .= '<tr bgcolor="#bdc7d8" align=right>';
$headers = array();
$headers[] = "";
$headers[] = xhprof_xhprof_render_link("Run #{$run1}", $href1);
$headers[] = xhprof_xhprof_render_link("Run #{$run2}", $href2);
$headers[] = 'Diff';
$headers[] = 'Diff%';
$rows = array();
if ($display_calls) {
$row = array(
array(
'data' => 'Number of function xhprof_Calls',
),
array(
'data' => xhprof_print_num($totals_1["ct"], $format_cbk["ct"]),
'class' => 'xhprof_micro',
),
array(
'data' => xhprof_print_num($totals_2["ct"], $format_cbk["ct"]),
'class' => 'xhprof_micro',
),
array(
'data' => xhprof_print_num($totals_2["ct"] - $totals_1["ct"], $format_cbk["ct"], TRUE),
'class' => 'xhprof_micro',
),
array(
'data' => xhprof_print_pct($totals_2["ct"] - $totals_1["ct"], $totals_1["ct"], TRUE),
'class' => 'xhprof_percent',
),
);
$rows[] = $row;
}
foreach ($metrics as $m) {
$desc = xhprof_stat_description($m, $desc = FALSE);
$row = array(
array(
'data' => str_replace("<br>", " ", $desc),
),
array(
'data' => xhprof_print_num($totals_1[$m], $format_cbk[$m]),
'class' => 'xhprof_micro',
),
array(
'data' => xhprof_print_num($totals_2[$m], $format_cbk[$m]),
'class' => 'xhprof_micro',
),
array(
'data' => xhprof_print_num($totals_2[$m] - $totals_1[$m], $format_cbk[$m], TRUE),
'class' => 'xhprof_micro',
),
array(
'data' => xhprof_print_pct($totals_2[$m] - $totals_1[$m], $totals_1[$m], TRUE),
'class' => 'xhprof_percent',
),
);
$rows[] = $row;
}
$attributes = array(
'class' => array(
'xhprof-table',
'xhprof-summary-table',
),
);
$output .= theme('table', array(
'header' => $headers,
'rows' => $rows,
'attributes' => $attributes,
));
$callgraph_report_title = '[View Regressions/Improvements using Callgraph Diff]';
}
else {
$vars = array(
'totals' => $totals,
'possible_metrics' => $possible_metrics,
'metrics' => $metrics,
'display_calls' => $display_calls,
);
$output .= theme('xhprof_overall_summary', $vars);
}
$output .= "<center><br><h3>";
//$output .= xhprof_xhprof_render_link($callgraph_report_title, "$base_path/callgraph.php" . "?" . http_build_query($url_params));
$output .= "</h3></center>";
$flat_data = array();
foreach ($symbol_tab as $symbol => $info) {
$tmp = $info;
$tmp["fn"] = $symbol;
$flat_data[] = $tmp;
}
usort($flat_data, 'xhprof_sort_cbk');
$output .= "<br>";
if (!empty($url_params['all'])) {
$all = TRUE;
$limit = 0;
// display all rows
}
else {
$all = FALSE;
$limit = 100;
// display only limited number of rows
}
$desc = str_replace("<br>", " ", $descriptions[$sort_col]);
if ($diff_mode) {
if ($all) {
$title = "Total Diff Report: '\n .'Sorted by absolute value of regression/improvement in {$desc}";
}
else {
$title = "Top 100 <em style='color:red'>Regressions</em>/" . "<em style='color:green'>Improvements</em>: " . "Sorted by {$desc} Diff";
}
}
else {
if ($all) {
$title = "Sorted by {$desc}";
}
else {
$title = "Displaying top {$limit} functions: Sorted by {$desc}";
}
}
$vars = array(
'stats' => $stats,
'totals' => $totals,
'url_params' => $url_params,
'title' => $title,
'flat_data' => $flat_data,
'limit' => $limit,
'run1' => $run1,
'run2' => $run2,
);
$output .= theme('xhprof_run_table', $vars);
return $output;
}