You are here

function performance_view_details in Performance Logging and Monitoring 6

Same name and namespace in other branches
  1. 5 performance.module \performance_view_details()
  2. 6.2 includes/performance.details.inc \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
Implementation of hook_menu().

File

./performance.module, line 1126
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_view_details() {
  drupal_set_title(t('Performance logs: 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'), PERFORMANCE_SETTINGS),
    ));
  }
  $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('ms (Total)'),
      'field' => 'ms',
    ),
    array(
      'data' => t('Anonymous?'),
      'field' => 'anon',
    ),
  );
  if (variable_get(PERFORMANCE_QUERY_VAR, 0)) {
    $header[] = array(
      'data' => t('# Queries'),
      'field' => 'query_count',
    );
    $header[] = array(
      'data' => t('Query ms'),
      'field' => 'query_timer',
    );
  }
  $pager_height = 50;
  $sql = 'SELECT * FROM {performance_detail}';
  $tablesort = tablesort_sql($header);
  $result = pager_query($sql . $tablesort, $pager_height);
  $rows = array();
  while ($data = db_fetch_object($result)) {
    $row_data = array();
    $row_data[] = $data->pid;
    $row_data[] = format_date($data->timestamp, 'small');
    $row_data[] = l(check_plain($data->path), $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[] = array(
      'data' => $row_data,
    );
  }
  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;
}