You are here

function performance_log_summary_db in Performance Logging and Monitoring 6

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

Helper function to store summary data in database.

See also

performance_data_stores()

File

./performance.module, line 819
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()) {
  $row = db_fetch_object(db_query("SELECT * FROM {performance_summary} WHERE path = '%s'", $params['path']));
  $result = performance_build_summary_data($row, $params);
  if ($result['type'] == 'existing') {

    // Update record based on path.
    db_query('UPDATE {performance_summary}
      SET last_access = %d,
      bytes_max = %d,
      bytes_avg = %d,
      ms_max = %d,
      ms_avg = %d,
      query_timer_max = %d,
      query_timer_avg = %d,
      query_count_max = %d,
      query_count_avg = %d,
      num_accesses = %d
      WHERE path = "%s"', array_values($result['data']));
  }
  else {

    // First time we log this path, write fresh values.
    db_query('INSERT INTO {performance_summary}
      (last_access, bytes_max, bytes_avg, ms_max, ms_avg,
      query_timer_max, query_timer_avg, query_count_max, query_count_avg,
      num_accesses, path)
      VALUES(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, "%s")', array_values($result['data']));
  }
}