Last active
February 28, 2017 11:38
-
-
Save maartendekeizer/69719cb1de6ced7f84dfb3a1cd18e143 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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