You are here

function performance_build_summary_data in Performance Logging and Monitoring 7.2

Same name and namespace in other branches
  1. 6.2 performance.module \performance_build_summary_data()
  2. 6 performance.module \performance_build_summary_data()
  3. 7 performance.module \performance_build_summary_data()

Helper function to build summary data array.

Parameters

data array of previous data:

params array of current data:

Return value

array holding summary data

1 call to performance_build_summary_data()
performance_log_summary in ./performance.module
Store the summary data.

File

./performance.module, line 361
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_build_summary_data($data, $params) {
  if ($data) {
    $type = 'existing';
    $data = array(
      'path' => $data['path'],
      'bytes_max' => max($params['mem'], $data['bytes_max']),
      'bytes_sum' => $data['bytes_sum'] + $params['mem'],
      'ms_max' => max($params['timer'], $data['ms_max']),
      'ms_sum' => $data['ms_sum'] + $params['timer'],
      'query_timer_max' => max($params['query_timer'], $data['query_timer_max']),
      'query_timer_sum' => $data['query_timer_sum'] + $params['query_timer'],
      'query_count_max' => max($params['query_count'], $data['query_count_max']),
      'query_count_sum' => $data['query_count_sum'] + $params['query_count'],
      'num_accesses' => $data['num_accesses'] + 1,
      'last_access' => REQUEST_TIME,
      'anon' => $params['anon'],
      'language' => $params['language'],
    );
  }
  else {
    $type = 'new';
    $data = array(
      'path' => $params['path'],
      'bytes_max' => $params['mem'],
      'bytes_sum' => $params['mem'],
      'ms_max' => (int) $params['timer'],
      'ms_sum' => (int) $params['timer'],
      'query_timer_max' => $params['query_timer'],
      'query_timer_sum' => $params['query_timer'],
      'query_count_max' => (int) $params['query_count'],
      'query_count_sum' => (int) $params['query_count'],
      'num_accesses' => 1,
      'last_access' => REQUEST_TIME,
      'anon' => $params['anon'],
      'language' => $params['language'],
    );
  }
  return array(
    'data' => $data,
    'type' => $type,
  );
}