You are here

function performance_log_summary_db in Performance Logging and Monitoring 5

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

File

./performance.module, line 261

Code

function performance_log_summary_db($params = array()) {
  $result = db_query("SELECT * FROM {performance_summary} WHERE path = '%s'", $params['path']);
  if (db_num_rows($result)) {
    $row = db_fetch_object($result);
    db_query("UPDATE {performance_summary} \n      SET last_access = %d,\n      num_accesses = num_accesses + 1,\n      bytes_max = %d,\n      bytes_avg = %d,\n      millisecs_max = %d,\n      millisecs_avg = %d,\n      query_timer_max = %d,\n      query_timer_avg = %d,\n      query_count_max = %d,\n      query_count_avg = %d\n      WHERE path = '%s'", time(), max($params['mem'], $row->bytes_max), ($row->bytes_avg + $params['mem']) / 2, max($params['timer'], $row->millisecs_max), ($row->millisecs_avg + $params['timer']) / 2, max($params['query_timer'], $row->query_timer_max), ($row->query_timer_avg + $params['query_timer']) / 2, max($params['query_count'], $row->query_count_max), ($row->query_count_avg + $params['query_count']) / 2, $params['path']);
  }
  else {

    // First time we log this path, write fresh values
    db_query("INSERT INTO {performance_summary}\n      (title, path, last_access, num_accesses,\n      bytes_max, bytes_avg, millisecs_max, millisecs_avg,\n      query_count_max, query_count_avg, query_timer_max, query_timer_avg)\n      VALUES \n      ('%s', '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", strip_tags(drupal_get_title()), $params['path'], time(), 1, $params['mem'], $params['mem'], $params['timer'], $params['timer'], $params['query_count'], $params['query_count'], $params['query_timer'], $params['query_timer']);
  }
}