? ms.patch
Index: performance/performance.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/devel/performance/performance.install,v
retrieving revision 1.12
diff -u -p -r1.12 performance.install
--- performance/performance.install 13 Sep 2009 12:11:29 -0000 1.12
+++ performance/performance.install 25 Dec 2009 10:17:36 -0000
@@ -4,6 +4,7 @@
/**
* @file
* Install and update for Performance Logging
+ *
* Copyright Khalid Baheyeldin 2008 of http://2bits.com
*/
@@ -16,8 +17,8 @@ function performance_schema() {
'last_access' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'bytes_max' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'bytes_avg' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
- 'millisecs_max' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
- 'millisecs_avg' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
+ 'ms_max' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
+ 'ms_avg' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'query_count_max' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'query_count_avg' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'query_timer_max' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
@@ -34,7 +35,7 @@ function performance_schema() {
'pid' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'),
'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'bytes' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
- 'millisecs' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
+ 'ms' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'query_count' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'query_timer' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'anon' => array('type' => 'int', 'not null' => FALSE, 'default' => 1, 'disp-width' => '1'),
@@ -124,3 +125,23 @@ function performance_update_2() {
db_add_field($ret, 'performance_detail', 'data', array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'));
return $ret;
}
+
+/**
+ * Harmonize notations for milliseconds to "ms".
+ *
+ * @return array
+ */
+function performance_update_7001() {
+ $int_field = array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11');
+
+ $ret = array();
+ db_change_field($ret, 'performance_summary', 'millisecs_max', 'ms_max', $int_field);
+ db_change_field($ret, 'performance_summary', 'millisecs_avg', 'ms_avg', $int_field);
+ db_change_field($ret, 'performance_detail', 'millisecs', 'ms', $int_field);
+
+ // We don't have a cache update method, so it's better to clear it
+ if (!function_exists('apc_fetch')) {
+ apc_clear_cache('user');
+ }
+ return $ret;
+}
Index: performance/performance.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/devel/performance/performance.module,v
retrieving revision 1.29
diff -u -p -r1.29 performance.module
--- performance/performance.module 20 Nov 2009 20:54:41 -0000 1.29
+++ performance/performance.module 25 Dec 2009 10:17:37 -0000
@@ -3,7 +3,9 @@
/**
* @file
- * Logs detailed and/or summary page generation time and memory consumption for page requests.
+ * Logs detailed and/or summary page generation time and memory consumption for
+ * page requests.
+ *
* Copyright Khalid Baheyeldin 2008 of http://2bits.com
*/
@@ -209,8 +211,8 @@ function performance_log_summary_apc($pa
'last_access' => REQUEST_TIME,
'bytes_max' => max($params['mem'], $data['bytes_max']),
'bytes_avg' => ($data['bytes_avg'] + $params['mem']) / 2,
- 'millisecs_max' => max($params['timer'], $data['millisecs_max']),
- 'millisecs_avg' => ($data['millisecs_avg'] + $params['timer']) / 2,
+ 'ms_max' => max($params['timer'], $data['ms_max']),
+ 'ms_avg' => ($data['ms_avg'] + $params['timer']) / 2,
'query_timer_max' => max($params['query_timer'], $data['query_timer_max']),
'query_timer_avg' => ($data['query_timer_avg'] + $params['query_timer']) / 2,
'query_count_max' => max($params['query_count'], $data['query_count_max']),
@@ -223,8 +225,8 @@ function performance_log_summary_apc($pa
'path' => $params['path'],
'bytes_max' => $params['mem'],
'bytes_avg' => $params['mem'],
- 'millisecs_max' => $params['timer'],
- 'millisecs_avg' => $params['timer'],
+ 'ms_max' => $params['timer'],
+ 'ms_avg' => $params['timer'],
'query_timer_max' => $params['query_timer'],
'query_timer_avg' => $params['query_timer'],
'query_count_max' => $params['query_count'],
@@ -246,8 +248,8 @@ function performance_log_summary_db($par
'num_accesses' => $row->num_accesses + 1,
'bytes_max' => max($params['mem'], $row->bytes_max),
'bytes_avg' => ($row->bytes_avg + $params['mem']) / 2,
- 'millisecs_max' => max($params['timer'], $row->millisecs_max),
- 'millisecs_avg' => ($row->millisecs_avg + $params['timer']) / 2,
+ 'ms_max' => max($params['timer'], $row->ms_max),
+ 'ms_avg' => ($row->ms_avg + $params['timer']) / 2,
'query_timer_max' => max($params['query_timer'], $row->query_timer_max),
'query_timer_avg' => ($row->query_timer_avg + $params['query_timer']) / 2,
'query_count_max' => max($params['query_count'], $row->query_count_max),
@@ -262,8 +264,8 @@ function performance_log_summary_db($par
'num_accesses' => 1,
'bytes_max' => $params['mem'],
'bytes_avg' => $params['mem'],
- 'millisecs_max' => $params['timer'],
- 'millisecs_avg' => $params['timer'],
+ 'ms_max' => $params['timer'],
+ 'ms_avg' => $params['timer'],
'query_timer_max' => $params['query_count'],
'query_timer_avg' => $params['query_count'],
'query_count_max' => $params['query_timer'],
@@ -282,7 +284,7 @@ function performance_log_details($params
$fields = array(
'timestamp' => REQUEST_TIME,
'bytes' => $params['mem'],
- 'millisecs' => $params['timer'],
+ 'ms' => $params['timer'],
'query_count' => $params['query_count'],
'query_timer' => $params['query_timer'],
'anon' => ($user->uid) ? 0 : 1,
@@ -348,7 +350,7 @@ function performance_view_summary() {
$go = array_sum($sum);
if (!$go) {
- return t('Summary performance log is not enabled. Go to the settings page to enable it.',
+ return t('Summary performance log is not enabled. Go to the settings page to enable it.',
array('!link' => url('admin/config/development/performance_logging')));
}
@@ -357,19 +359,19 @@ function performance_view_summary() {
$header[] = array('data' => t('Path'), 'field' => 'path');
$header[] = array('data' => t('Last access'), 'field' => 'last_access');
$header[] = array('data' => t('# accesses'), 'field' => 'num_accesses');
- $header[] = array('data' => t('Max Memory (MB)'), 'field' => 'bytes_max');
- $header[] = array('data' => t('Avg Memory (MB)'), 'field' => 'bytes_avg');
- $header[] = array('data' => t('Milliseconds (Max)'), 'field' => 'millisecs_max');
- $header[] = array('data' => t('Milliseconds (Avg)'), 'field' => 'millisecs_avg');
+ $header[] = array('data' => t('MB Memory (Max)'), 'field' => 'bytes_max');
+ $header[] = array('data' => t('MB Memory (Avg)'), 'field' => 'bytes_avg');
+ $header[] = array('data' => t('ms (Max)'), 'field' => 'ms_max');
+ $header[] = array('data' => t('ms (Avg)'), 'field' => 'ms_avg');
if (variable_get('performance_query', 0)) {
- $header[] = array('data' => t('Query Millisecs (Max)'), 'field' => 'query_timer_max');
- $header[] = array('data' => t('Query Millisecs (Avg)'), 'field' => 'query_timer_avg');
- $header[] = array('data' => t('Query Count (Max)'), 'field' => 'query_count_max');
- $header[] = array('data' => t('Query Count (Avg)'), 'field' => 'query_count_avg');
+ $header[] = array('data' => t('Query ms (Max)'), 'field' => 'query_timer_max');
+ $header[] = array('data' => t('Query ms (Avg)'), 'field' => 'query_timer_avg');
+ $header[] = array('data' => t('Query Count (Max)'), 'field' => 'query_count_max');
+ $header[] = array('data' => t('Query Count (Avg)'), 'field' => 'query_count_avg');
}
- $total_rows = $shown = $last_max = $total_bytes = $total_millisecs = $total_accesses = 0;
+ $total_rows = $shown = $last_max = $total_bytes = $total_ms = $total_accesses = 0;
$last_min = REQUEST_TIME;
$threshold = variable_get('performance_threshold_accesses', 0);
@@ -384,22 +386,22 @@ function performance_view_summary() {
$data_list[] = apc_fetch($key) + $tablesort;
}
usort($data_list, 'performance_summary_sort');
-
+
// Set up pager since this is not done automatically when not using DB
$page = isset($_GET['page']) ? $_GET['page'] : 0; // unsafe
$page = sprintf('%d', $page); // now safe
-
- global
+
+ global
$pager_page_array, // array of element-keyed current page - 1
$pager_total, // array of element-keyed total number of pages
- $pager_total_items, // array of element-keyed total number of data rows
+ $pager_total_items, // array of element-keyed total number of data rows
$pager_limits; // array of element-keyed number of rows per page
-
+
$pager_page_array = array(0 => $page);
$pager_total_items = array(0 => count($data_list));
$pager_limits = array(0 => $pager_height);
$pager_total = array(0 => ceil($pager_total_items[0] / $pager_limits[0]));
-
+
// Extract the data subset we need
$data_list = array_slice($data_list, $page * $pager_height, $pager_height);
}
@@ -422,7 +424,7 @@ function performance_view_summary() {
// Calculate running averages
$total_bytes += $data['bytes_avg'];
- $total_millisecs += $data['millisecs_avg'];
+ $total_ms += $data['ms_avg'];
$total_accesses += $data['num_accesses'];
$row_data = array();
@@ -434,8 +436,8 @@ function performance_view_summary() {
$row_data[] = $data['num_accesses'];
$row_data[] = number_format($data['bytes_max']/1024/1024, 2);
$row_data[] = number_format($data['bytes_avg']/1024/1024, 2);
- $row_data[] = number_format($data['millisecs_max'], 1);
- $row_data[] = number_format($data['millisecs_avg'], 1);
+ $row_data[] = number_format($data['ms_max'], 1);
+ $row_data[] = number_format($data['ms_avg'], 1);
if (variable_get('performance_query', 0)) {
$row_data[] = number_format($data['query_timer_max'], 1);
$row_data[] = number_format($data['query_timer_avg'], 1);
@@ -462,7 +464,7 @@ function performance_view_summary() {
// Protect against divide by zero
if ($total_rows > 0) {
$mb_avg = number_format($total_bytes/$total_rows/1024/1024, 1);
- $ms_avg = number_format($total_millisecs/$total_rows, 2);
+ $ms_avg = number_format($total_ms/$total_rows, 2);
}
else {
$mb_avg = 'n/a';
@@ -470,23 +472,23 @@ function performance_view_summary() {
}
$output .= t('Average memory per page: !mb_avg MB', array('!mb_avg' => $mb_avg)) . '
';
- $output .= t('Average milliseconds per page: !ms_avg', array('!ms_avg' => $ms_avg)) . '
';
+ $output .= t('Average ms per page: !ms_avg', array('!ms_avg' => $ms_avg)) . '
';
$output .= t('Total number of page accesses: !accesses', array('!accesses' => $total_accesses)) . '
';
$output .= t('First access: !access.', array('!access' => format_date($last_min, 'small'))) . '
';
$output .= t('Last access: !access.', array('!access' => format_date($last_max, 'small'))) . '
';
$output .= theme_table(array(
- 'header' => $header,
- 'rows' => $rows,
+ 'header' => $header,
+ 'rows' => $rows,
'attributes' => array(),
'caption' => NULL,
'colgroups' => NULL,
'sticky' => TRUE,
));
$output .= theme_pager(array(
- 'tags' => NULL,
- 'element' => 0,
- 'parameters' => $header,
+ 'tags' => NULL,
+ 'element' => 0,
+ 'parameters' => $header,
'quantity' => 9));
return $output;
@@ -502,13 +504,13 @@ function performance_view_details() {
array('data' => t('Date'), 'field' => 'timestamp'),
array('data' => t('Path'), 'field' => 'path'),
array('data' => t('Memory (MB)'), 'field' => 'bytes'),
- array('data' => t('Milliseconds (Total)'), 'field' => 'millisecs'),
+ array('data' => t('ms (Total)'), 'field' => 'ms'),
array('data' => t('Anonymous?'), 'field' => 'anon'),
);
if (variable_get('performance_query', 0)) {
- $header[] = array('data' => t('# Queries'), 'field' => 'query_count');
- $header[] = array('data' => t('Query Milliseconds'), 'field' => 'query_timer');
+ $header[] = array('data' => t('# Queries'), 'field' => 'query_count');
+ $header[] = array('data' => t('Query ms'), 'field' => 'query_timer');
}
$pager_height = 50;
@@ -524,7 +526,7 @@ function performance_view_details() {
$row_data[] = format_date($data->timestamp, 'small');
$row_data[] = $data->path;
$row_data[] = number_format($data->bytes/1024/1024, 2);
- $row_data[] = $data->millisecs;
+ $row_data[] = $data->ms;
$row_data[] = ($data->anon) ? t('Yes') : t('No');
if (variable_get('performance_query', 0)) {
@@ -654,7 +656,7 @@ function performance_nagios() {
}
// Initialize variables
- $total_rows = $total_bytes = $total_millisecs = $total_accesses = $total_query_time = $total_query_count = 0;
+ $total_rows = $total_bytes = $total_ms = $total_accesses = $total_query_time = $total_query_count = 0;
// Check which data store to use
if (variable_get('performance_summary_apc', 0) && function_exists('apc_cache_info')) {
@@ -676,7 +678,7 @@ function performance_nagios() {
// Calculate running averages
$total_bytes += $data['bytes_avg'];
- $total_millisecs += $data['millisecs_avg'];
+ $total_ms += $data['ms_avg'];
$total_accesses += $data['num_accesses'];
$total_query_time += $data['query_timer_avg'];
$total_query_count += $data['query_count_avg'];
@@ -684,7 +686,7 @@ function performance_nagios() {
// Protect against divide by zero
if ($total_rows > 0) {
- $ms_avg = number_format($total_millisecs / $total_rows, 1, '.', '');
+ $ms_avg = number_format($total_ms / $total_rows, 1, '.', '');
$ms_query = number_format($total_query_time / $total_rows, 1, '.', '');
$query_count = number_format($total_query_count / $total_rows, 2, '.', '');
$mb_avg = number_format($total_bytes / $total_rows/1024/1024, 1);
@@ -726,4 +728,3 @@ function performance_nagios() {
),
);
}
-