function drush_performance_details in Performance Logging and Monitoring 6.2
Same name and namespace in other branches
- 6 performance.drush.inc \drush_performance_details()
- 7.2 performance.drush.inc \drush_performance_details()
- 7 performance.drush.inc \drush_performance_details()
1 string reference to 'drush_performance_details'
- performance_drush_command in ./
performance.drush.inc - Implementation of hook_drush_command().
File
- ./
performance.drush.inc, line 183 - Drush integration for the Performance module.
Code
function drush_performance_details() {
$header = array(
dt('#'),
dt('Date'),
dt('Path'),
dt('Memory (MB)'),
dt('ms (Total)'),
dt('Anonymous?'),
);
if (variable_get(PERFORMANCE_QUERY_VAR, 0)) {
$header[] = dt('# Queries');
$header[] = dt('Query ms');
}
$rows[] = $header;
// Collect arguments.
$args = func_get_args();
$orderby = 'timestamp';
$columns = array(
'pid',
'timestamp',
'bytes',
'ms',
'anon',
'path',
);
if (variable_get(PERFORMANCE_QUERY_VAR, 0)) {
$columns[] = 'query_count';
$columns[] = 'query_timer';
}
$arguments = drush_performance_parse_args($args, $orderby, $columns);
// Error thrown, abort.
if (!is_array($arguments)) {
return $arguments;
}
$data_list = drush_performance_get_detail($arguments);
if (empty($data_list) && !variable_get('performance_detail', 0)) {
return drush_set_error(dt('Detail performance log is not enabled! Go to the settings page to enable it.'));
}
elseif (empty($data_list)) {
return drush_print("\33[1m" . dt('No log messages available.') . "\33[0m", 1);
}
elseif (!variable_get('performance_detail', 0)) {
drush_print("\33[1;33m" . dt('Detail performance log is not enabled! Showing stored logs.') . "\33[0m\n", 1);
}
foreach ($data_list as $data) {
// Cast to object because of the DB API now returning row objects by default.
$data = is_array($data) ? (object) $data : $data;
$row_data = array();
$row_data[] = $data->pid;
$row_data[] = format_date($data->timestamp, 'small');
$row_data[] = check_plain($data->path);
$row_data[] = number_format($data->bytes / 1024 / 1024, 2);
$row_data[] = $data->ms;
$row_data[] = $data->anon ? t('Yes') : t('No');
if (variable_get(PERFORMANCE_QUERY_VAR, 0)) {
$row_data[] = $data->query_count;
$row_data[] = $data->query_timer;
}
$rows[] = $row_data;
}
drush_print("\33[1m" . dt('Performance log details: !rows entries ordered by !column, !direction', array(
'!rows' => count($rows) - 1,
'!column' => $arguments['orderby'],
'!direction' => $arguments['direction'],
)) . "\33[0m", 1);
drush_print_table($rows, TRUE);
}