summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--performance/performance.module38
1 files changed, 37 insertions, 1 deletions
diff --git a/performance/performance.module b/performance/performance.module
index c80bf34..b3c83b8 100644
--- a/performance/performance.module
+++ b/performance/performance.module
@@ -307,6 +307,40 @@ function performance_apc_list_all() {
return $key_list;
}
+/**
+ * Custom sort for summary performance report
+ *
+ * @param $x
+ * @param $y
+ * @return int
+ */
+function performance_summary_sort($x, $y) {
+
+ $epsilon = 1E-8; // arbitrary (mostly)
+
+ $column = $x['sql']; // N.B.: === $y['sql']
+ // These arrays only contain integer and float values, so can use "-"
+ $diff = $x[$column] - $y[$column];
+
+ // Specific floating-point equality test
+ if (gettype($x[$column]) == 'float') {
+ if (abs($diff) < $epsilon) {
+ return 0;
+ }
+ }
+
+ if ($diff === 0) { // Will never happen for floats
+ return 0;
+ }
+ else {
+ $ret = ($diff < 0) ? -1 : 1;
+ if ($x['sort'] == 'desc') {
+ $ret = - $ret;
+ }
+ return $ret;
+ }
+}
+
function performance_view_summary() {
$sum = array();
$sum[] = variable_get('performance_summary_db', 0);
@@ -340,10 +374,12 @@ function performance_view_summary() {
$threshold = variable_get('performance_threshold_accesses', 0);
if (variable_get('performance_summary_apc', 0) && function_exists('apc_cache_info')) {
+ $tablesort = tablesort_init($header);
// Get the data from the APC cache
foreach (performance_apc_list_all() as $key) {
- $data_list[] = apc_fetch($key);
+ $data_list[] = apc_fetch($key) + $tablesort;
}
+ usort($data_list, 'performance_summary_sort');
}
else {
// Get the data form the database table