function performance_shutdown in Performance Logging and Monitoring 6.2
Same name and namespace in other branches
- 5 performance.module \performance_shutdown()
- 6 performance.module \performance_shutdown()
- 7.2 performance.module \performance_shutdown()
- 7 performance.module \performance_shutdown()
Shutdown function that collects all performance data.
1 string reference to 'performance_shutdown'
- performance_boot in ./
performance.module - Implementation of hook_boot().
File
- ./
performance.module, line 250 - 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_shutdown() {
global $queries, $user, $language;
// Don't log drush access.
if (performance_is_cli() && variable_get('performance_nodrush', 1)) {
return;
}
if (isset($_GET['q']) && $_GET['q']) {
// q= has a value, use that for the path
$path = $_GET['q'];
}
elseif (performance_is_cli()) {
$path = 'drush';
}
else {
// q= is empty, use whatever the site_frontpage is set to
$path = variable_get('site_frontpage', 'node');
}
// Skip certain paths defined by the user.
if (drupal_match_path($path, variable_get('performance_skip_paths', ''))) {
return;
}
$params = array(
'timer' => timer_read('page'),
'path' => $path,
);
// Memory
if (function_exists('memory_get_peak_usage')) {
$params['mem'] = memory_get_peak_usage(TRUE);
}
else {
$params['mem'] = 0;
}
// Query time and count
$query_count = $query_timer = $sum = 0;
if (variable_get(PERFORMANCE_QUERY_VAR, 0) && is_array($queries)) {
foreach ($queries as $query) {
$sum += $query[1];
}
$query_count = count($queries);
$query_timer = round($sum * 1000, 2);
}
$params['query_count'] = $query_count;
$params['query_timer'] = $query_timer;
// Anonymous access?
$params['anon'] = $user->uid ? 0 : 1;
// Language
$params['language'] = $language->language;
// There used to be a module_invoke_all('performance', 'header', $header) call
// here but it has been removed. $header was an associative array containing
// path, timer (ms) and anon ('Yes' or 'No').
if (variable_get('performance_detail', 0)) {
// There used to be a module_invoke_all('performance', 'data') call here. As
// it was undocumented and therefore unknown, it has been removed. The data
// column has been kept so that we can re-implement if needed.
$params['data'] = NULL;
performance_log_details($params);
}
// There used to be a module_invoke_all('performance', 'disable') call here in
// an else statement.
if (variable_get('performance_summary', 0)) {
performance_log_summary($params);
}
}