Guest User

Untitled

a guest
Oct 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. <?php
  2. $startTime = microtime(true);
  3. $dbh = new PDO('mysql:dbname=php_mysqltest;host=localhost', 'php', 'php');
  4.  
  5. for($i = 0; $i < 90000; $i++) {
  6. $st = $dbh->prepare('INSERT INTO test (`test_int`, `test_float`, `test_string`) VALUES (:int, :float, :string)');
  7. $st->bindValue(':int', mt_rand(), PDO::PARAM_INT);
  8. $st->bindValue(':float', mt_rand()/mt_rand()*10);
  9. $st->bindValue(':string', sha1(mt_rand()));
  10.  
  11. $st->execute();
  12. unset($st);
  13. }
  14. $endTime = microtime(true);
  15. echo 'Inserting ', $i, ' rows took ', $endTime - $startTime, ' seconds';
Add Comment
Please, Sign In to add comment