You are here

function performance_log_summary_apc in Performance Logging and Monitoring 5

Same name and namespace in other branches
  1. 6 performance.module \performance_log_summary_apc()
  2. 7 performance.module \performance_log_summary_apc()
1 call to performance_log_summary_apc()
performance_shutdown in ./performance.module

File

./performance.module, line 224

Code

function performance_log_summary_apc($params = array()) {
  $key = PERFORMANCE_KEY . $params['path'];
  if ($data = apc_fetch($key)) {
    $data = array(
      'path' => $data['path'],
      'last_access' => time(),
      'bytes_max' => max($params['mem'], $data['bytes_max']),
      'bytes_avg' => ($data['bytes_avg'] + $params['mem']) / 2,
      'millisecs_max' => max($params['timer'], $data['millisecs_max']),
      'millisecs_avg' => ($data['millisecs_avg'] + $params['timer']) / 2,
      'query_timer_max' => max($params['query_timer'], $row->query_timer_max),
      'query_timer_avg' => ($row->query_timer_avg + $params['query_timer']) / 2,
      'query_count_max' => max($params['query_count'], $row->query_count_max),
      'query_count_avg' => ($row->query_count_avg + $params['query_count']) / 2,
      'num_accesses' => $data['num_accesses'] + 1,
      'title' => $data['title'],
    );
  }
  else {
    $data = array(
      'title' => strip_tags(drupal_get_title()),
      'path' => $params['path'],
      'bytes_max' => $params['mem'],
      'bytes_avg' => $params['mem'],
      'millisecs_max' => $params['timer'],
      'millisecs_avg' => $params['timer'],
      'query_timer_max' => $params['query_timer'],
      'query_timer_avg' => $params['query_timer'],
      'query_count_max' => $params['query_count'],
      'query_count_avg' => $params['query_count'],
      'num_accesses' => 1,
      'last_access' => time(),
    );
  }
  apc_store($key, $data);
}