fork(3) download
  1. <?php
  2. function test($x)
  3. {
  4. $t1 = microtime(true);
  5. $a = 0;
  6. for($i = 0; $i < $x; ++$i)
  7. {
  8. //1.40s Reassign and use $a.
  9. //$a += 1;
  10. //1.15s Use and increment $a.
  11. //$a++;
  12. //0.88s Increment and use $a.
  13. //++$a;
  14. //0.69s Do nothing.
  15. }
  16. $t2 = microtime(true);
  17. echo "Time for $x was " . ($t2 - $t1) . "\n";
  18. return $a;
  19. }
  20. echo test(1e8);
Success #stdin #stdout 0.73s 23612KB
stdin
Standard input is empty
stdout
Time for 100000000 was 0.70396995544434
0