fork download
  1. <?php
  2.  
  3. $a = range(1,10000);
  4.  
  5. function bcMicroTime() {
  6. $temp = explode(" ", microtime());
  7. return bcadd($temp[0], $temp[1], 6);
  8. }
  9.  
  10. $foreachStart = bcMicroTime();
  11. foreach ($a as $b) {};
  12. $foreachStop = bcMicroTime();
  13.  
  14. $arraymapStart = bcMicroTime();
  15. array_map(function($b) {}, $a);
  16. $arraymapStop = bcMicroTime();
  17.  
  18. $timeOverall = bcsub($foreachStop, $foreachStart, 6);
  19. echo "foreach execution time - $timeOverall seconds";
  20.  
  21. $timeOverall = bcsub($arraymapStop, $arraymapStart, 6);
  22. echo "\narray_map execution time - $timeOverall seconds";
Success #stdin #stdout 0.03s 52432KB
stdin
Standard input is empty
stdout
foreach execution time   - 0.000791 seconds
array_map execution time - 0.008499 seconds