Created
July 24, 2018 09:37
-
-
Save php-cpm/dc5bc659ecb7732ccc890d852b5ee56e to your computer and use it in GitHub Desktop.
This file contains 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 | |
// refer & edit from https://odino.org/redis-slow-with-php-think-again/ | |
$conn = mysqli_connect('127.0.0.1', 'root'); | |
mysqli_select_db($conn, 'mysql_benchmark'); | |
for ($i = 0; $i < 100; $i++) { | |
$start = microtime(true); | |
for ($j = 0; $j < 10000; $j++) { | |
$query = mysqli_query($conn, 'SELECT * FROM users WHERE id = 1'); | |
$key = sprintf("key:%05d", $j); | |
$persone = mysqli_fetch_row($query); | |
} | |
$time = microtime(true)-$start; | |
printf("%6d req/sec\n", $j/$time); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo dtruss -c php mysql.php