You are here

function perfmon_test_db_read in Performance monitor 7

Same name and namespace in other branches
  1. 8 perfmon.module \perfmon_test_db_read()

Test db read operations.

1 string reference to 'perfmon_test_db_read'
_perfmon_performance_tests in ./perfmon.inc
Core Perfmon checks.

File

./perfmon.inc, line 255
Stand-alone perfmon test system.

Code

function perfmon_test_db_read() {
  $exectime = 0;
  $count = 1000;
  db_truncate('perfmon_test')
    ->execute();
  perfmon_test_db_prepare('test_db_read', $count);
  $exectime = microtime(TRUE);
  for ($i = 0; $i < $count; $i++) {
    $query = db_select('perfmon_test', 'pt');
    $query
      ->fields('pt', array(
      'id',
      'testname',
      'data',
    ));
    $query
      ->condition('pt.id', $i, '=');
    $query
      ->execute();
  }
  $exectime = microtime(TRUE) - $exectime;
  return array(
    'result' => round(1 / ($exectime / $count), 0),
    'value' => '0',
  );
}