Advertisement
Guest User

PHP Code

a guest
May 4th, 2011
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. <?php
  2.  
  3. // simple operations timing in PHP
  4. // Note this is not really a good measure of any language.
  5. // Who iterates over 1 million items and calls a function every time?
  6.  
  7. function addone($x) {
  8.     return $x+1;
  9. }
  10.  
  11. $t0 = microtime(TRUE);
  12. $x = 0;
  13. for ($i=0; $i<1000000; $i++) {
  14.     $x=addone($x);
  15. }
  16. $t1 = microtime(TRUE);
  17. print ($t1 - $t0);
  18.  
  19. echo "\n";
  20.  
  21. $t0 = microtime(TRUE);
  22. $x = 0;
  23. for ($i=0; $i<1000000; $i++) {
  24.     $x=$x+1;
  25. }
  26. $t1 = microtime(TRUE);
  27. print ($t1 - $t0);
  28.  
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement