You are here

function performance_build_summary_data in Performance Logging and Monitoring 7

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.2 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

4 calls to performance_build_summary_data()
performance_log_summary_apc in ./performance.module
Helper function to store summary data in APC.
performance_log_summary_db in ./performance.module
Helper function to store summary data in database.
performance_log_summary_memcache in ./performance.module
Helper function to store summary data in Memcache.
performance_log_summary_zend in ./performance.module
Helper function to store summary data in Zend Datacache.

File

./performance.module, line 399
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, $engine = '') {
  if (is_object($data)) {

    // Handle Memcache object.
    if (isset($data->data)) {
      $data = $data->data;
    }
    else {

      // Handle DB result row object.
      $data = (array) $data;
    }
  }
  if ($data) {
    $type = 'existing';
    $data = array(
      'last_access' => REQUEST_TIME,
      'bytes_max' => max($params['mem'], $data['bytes_max']),
      'bytes_avg' => performance_average($data['bytes_avg'], $params['mem'], $data['num_accesses']),
      'ms_max' => max($params['timer'], $data['ms_max']),
      'ms_avg' => performance_average($data['ms_avg'], $params['timer'], $data['num_accesses']),
      'query_timer_max' => max($params['query_timer'], $data['query_timer_max']),
      'query_timer_avg' => performance_average($data['query_timer_avg'], $params['query_timer'], $data['num_accesses']),
      'query_count_max' => max($params['query_count'], $data['query_count_max']),
      'query_count_avg' => performance_average($data['query_count_avg'], $params['query_count'], $data['num_accesses']),
      'num_accesses' => $data['num_accesses'] + 1,
      'path' => $data['path'],
    );

    // TODO: this is a quick fix. These lines broke DB summary logging!
    // See if zend really needs this!
    if ($engine == 'zend') {
      $data['updated'] = REQUEST_TIME;
    }
  }
  else {
    $type = 'new';
    $data = array(
      'last_access' => REQUEST_TIME,
      'bytes_max' => $params['mem'],
      'bytes_avg' => $params['mem'],
      'ms_max' => (int) $params['timer'],
      'ms_avg' => (int) $params['timer'],
      'query_timer_max' => $params['query_timer'],
      'query_timer_avg' => $params['query_timer'],
      'query_count_max' => (int) $params['query_count'],
      'query_count_avg' => (int) $params['query_count'],
      'num_accesses' => 1,
      'path' => $params['path'],
    );

    // TODO: this is a quick fix. These lines broke DB summary logging!
    // See if zend really needs this!
    if ($engine == 'zend') {
      $data['created'] = $data['updated'] = REQUEST_TIME;
    }
  }
  return array(
    'data' => $data,
    'type' => $type,
  );
}