Created
October 15, 2010 06:44
-
-
Save chobie/627733 to your computer and use it in GitHub Desktop.
Doctrine2とmysqliでのインサートの比較用
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 | |
// 本番環境ではやらないでね! | |
$mysqli = mysqli_init(); | |
$mysqli->real_connect("localhost","user_name","password","db_name"); | |
if($error = mysqli_connect_error()){ | |
throw new RuntimeException($error); | |
} | |
$mysqli->set_charset("utf8"); | |
$name = "Guilherme"; | |
$s = microtime(true); | |
$stmt = $mysqli->prepare("insert into users(name) values(?)"); | |
$stmt->bind_param("s",$name); | |
$mysqli->query("start transaction"); | |
for($i =0;$i<10000;$i++){ | |
$stmt->execute(); | |
} | |
$mysqli->commit(); | |
$e = microtime(true); | |
echo ($e - $s) . PHP_EOL; | |
$mysqli->query("truncate users"); | |
$mysqli->close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment