function xhprof_sort_cbk in XHProf 6
Same name and namespace in other branches
- 7 xhprof.inc \xhprof_sort_cbk()
Callback comparison operator (passed to usort() for sorting array of tuples) that compares array elements based on the sort column specified in $sort_col (global parameter).
@author Kannan
3 string references to 'xhprof_sort_cbk'
- xhprof_full_report in ./
xhprof.inc - Generates a tabular report for all functions. This is the top-level report.
- xhprof_print_pc_array in ./
xhprof.inc - xhprof_symbol_report in ./
xhprof.inc - Generates a report for a single function/symbol.
File
- ./
xhprof.inc, line 370
Code
function xhprof_sort_cbk($a, $b) {
global $diff_mode;
$sort_col = isset($_GET['sort']) ? $_GET['sort'] : 'wt';
if ($sort_col == "fn") {
// case insensitive ascending sort for function xhprof_names
$left = strtoupper($a["fn"]);
$right = strtoupper($b["fn"]);
if ($left == $right) {
return 0;
}
return $left < $right ? -1 : 1;
}
else {
// descending sort for all others
$left = isset($a[$sort_col]) ? $a[$sort_col] : '';
$right = isset($b[$sort_col]) ? $b[$sort_col] : '';
// if diff mode, sort by absolute value of regression/improvement
if ($diff_mode) {
$left = abs($left);
$right = abs($right);
}
if ($left == $right) {
return 0;
}
return $left > $right ? -1 : 1;
}
}