function performance_gather_summary_data in Performance Logging and Monitoring 6.2
Same name and namespace in other branches
- 6 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 716 - 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() {
// Data from last 15 minutes.
$timestamp = time() - 15 * 60;
$data_list = performance_traverse_cache('performance_get_summary', $timestamp);
// 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_sum'] / $data['num_accesses'];
$total_ms += $data['ms_sum'] / $data['num_accesses'];
$total_accesses += $data['num_accesses'];
$total_query_time += $data['query_timer_sum'] / $data['num_accesses'];
$total_query_count += $data['query_count_sum'] / $data['num_accesses'];
}
$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;
}