You are here

function perfmon_test_db_read in Performance monitor 8

Same name and namespace in other branches
  1. 7 perfmon.inc \perfmon_test_db_read()

Test db read operations.

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

File

./perfmon.module, line 243
Stand-alone perfmon test system.

Code

function perfmon_test_db_read() {
  $executeTime = 0;
  $count = 1000;
  \Drupal::database()
    ->truncate('perfmon_test')
    ->execute();
  perfmon_test_db_prepare('test_db_read', $count);
  $executeTime = microtime(TRUE);
  for ($i = 0; $i < $count; $i++) {
    \Drupal::database()
      ->select('perfmon_test', 'pt')
      ->fields('pt', [
      'id',
      'testname',
      'data',
    ])
      ->condition('pt.id', $i, '=')
      ->execute();
  }
  $executeTime = microtime(TRUE) - $executeTime;
  return array(
    'result' => round(1 / ($executeTime / $count), 0),
    'value' => '0',
  );
}