You are here

function performance_view_details in Performance Logging and Monitoring 5

Same name and namespace in other branches
  1. 6.2 includes/performance.details.inc \performance_view_details()
  2. 6 performance.module \performance_view_details()
  3. 7.2 includes/performance.details.inc \performance_view_details()
  4. 7 performance.module \performance_view_details()
1 string reference to 'performance_view_details'
performance_menu in ./performance.module

File

./performance.module, line 448

Code

function performance_view_details() {
  if (!variable_get('performance_detail', 0)) {
    return t('Detail performance log is not enabled. Go to the !link to enable it.', array(
      '!link' => l(t('settings page'), 'admin/settings/performance_logging'),
    ));
  }
  $header = array(
    array(
      'data' => t('#'),
      'field' => 'pid',
      'sort' => 'desc',
    ),
    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('Anonymous?'),
      'field' => 'anon',
    ),
    array(
      'data' => t('# Queries'),
      'field' => 'query_count',
    ),
    array(
      'data' => t('Query Milliseconds'),
      'field' => 'query_timer',
    ),
  );
  $sql = "SELECT * FROM {performance_detail}";
  $tablesort = tablesort_sql($header);
  $result = pager_query($sql . $tablesort, 50);
  while ($data = db_fetch_array($result)) {
    $rows[] = array(
      'data' => array(
        $data['pid'],
        format_date($data['timestamp'], 'small'),
        performance_url($data['path'], $data['title']),
        number_format($data['bytes'] / 1024 / 1024, 2),
        $data['millisecs'],
        $data['anon'] ? t('Yes') : t('No'),
        $data['query_count'],
        $data['query_timer'],
      ),
    );
  }
  if (!$rows) {
    $rows[] = array(
      array(
        'data' => t('No log messages available.'),
        'colspan' => count($header),
      ),
    );
  }
  $output .= theme('table', $header, $rows);
  $output .= theme('pager', NULL, 50, 0);
  return $output;
}