You are here

function performance_log_summary_db in Performance Logging and Monitoring 7

Same name and namespace in other branches
  1. 5 performance.module \performance_log_summary_db()
  2. 6 performance.module \performance_log_summary_db()

Helper function to store summary data in database.

See also

performance_data_stores()

File

./performance.module, line 816
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_log_summary_db($params = array()) {

  // SQL: SELECT * FROM {performance_summary} WHERE path = '%s'
  $row = db_select('performance_summary', 'p')
    ->fields('p')
    ->condition('path', $params['path'])
    ->execute()
    ->fetch();
  $result = performance_build_summary_data($row, $params);
  if ($result['type'] == 'existing') {

    // Do not add the path field!
    unset($result['data']['path']);

    // Update record based on path.
    db_update('performance_summary')
      ->condition('path', $params['path'])
      ->fields($result['data'])
      ->execute();
  }
  else {

    // First time we log this path, write fresh values
    try {
      db_insert('performance_summary')
        ->fields($result['data'])
        ->execute();
    } catch (Exception $e) {
      watchdog_exception('performance', $e);
    }
  }
}