function performance_gather_summary_data in Performance Logging and Monitoring 6
Same name and namespace in other branches
- 6.2 performance.module \performance_gather_summary_data()
- 7.2 performance.module \performance_gather_summary_data()
- 7 performance.module \performance_gather_summary_data()
Gather performance data for external modules.
2 calls to performance_gather_summary_data()
- performance_nagios in ./
performance.module - Implementation of hook_nagios().
- performance_prod_check_return_data in ./
performance.module - Return performance data to Production Monitor.
File
- ./
performance.module, line 1268 - Logs detailed and/or summary page generation time and memory consumption for page requests. Copyright Khalid Baheyeldin 2008 of http://2bits.com
Code
function performance_gather_summary_data() {
$go = FALSE;
$data_list = array();
// Data from last 15 minutes.
$timestamp = time() - 15 * 60;
// Get data from first active store.
foreach (performance_data_stores() as $store => $data) {
if ($data['#enabled']) {
$data_list = call_user_func('performance_get_data_' . $store, $timestamp);
$go = TRUE;
break;
}
}
if (!$go) {
return FALSE;
}
// Initialize variables.
$total_rows = $total_bytes = $total_ms = $total_accesses = $total_query_time = $total_query_count = 0;
foreach ($data_list as $data) {
$total_rows++;
// Calculate running averages.
$total_bytes += $data['bytes_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'];
}
$results = array();
$results['total_accesses'] = $total_accesses;
// Protect against divide by zero.
if ($total_rows > 0) {
$results['ms_avg'] = number_format($total_ms / $total_rows, 1, '.', '');
$results['ms_query'] = number_format($total_query_time / $total_rows, 1, '.', '');
$results['query_count'] = number_format($total_query_count / $total_rows, 2, '.', '');
$results['mb_avg'] = number_format($total_bytes / $total_rows / 1024 / 1024, 1);
}
else {
$results['ms_avg'] = '';
$results['ms_query'] = '';
$results['mb_avg'] = '';
$results['query_count'] = '';
}
return $results;
}