Skip to content

Instantly share code, notes, and snippets.

@maartendekeizer
Last active February 28, 2017 11:38
Show Gist options
  • Save maartendekeizer/69719cb1de6ced7f84dfb3a1cd18e143 to your computer and use it in GitHub Desktop.
Save maartendekeizer/69719cb1de6ced7f84dfb3a1cd18e143 to your computer and use it in GitHub Desktop.
<?php
$host = '127.0.0.1';
$user = 'USER';
$password = 'PASSWORD';
echo 'php version ' . phpversion() . PHP_EOL;
$count = 1000;
echo 'test ' . $count . 'x connect + 1 system query' . PHP_EOL;
$start = microtime(true);
for ($i = 0; $i < $count; $i ++) {
$pdo = new \PDO('mysql:host=' . $host, $user, $password);
$pdo->query('SHOW DATABASES');
}
$end = microtime(true);
$dur = $end - $start;
echo 'total time ' . $dur . ' seconds' . PHP_EOL;
echo 'avg ' . ($dur / $count) . ' seconds' . PHP_EOL;
echo 'test 1x connect + ' . $count . 'x system query' . PHP_EOL;
$start = microtime(true);
$pdo = new \PDO('mysql:host=' . $host, $user, $password);
for ($i = 0; $i < $count; $i ++) {
$pdo->query('SHOW DATABASES');
}
$end = microtime(true);
$dur = $end - $start;
echo 'total time ' . $dur . ' seconds' . PHP_EOL;
echo 'avg ' . ($dur / $count) . ' seconds' . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment