3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = range(0, 1000, 1); $benchmarks = []; $runs = 100; $benchmarks['foreach'] = function ($array) { $newArray = []; foreach ($array as $item) { $newArray[] = $item * 2; } return $newArray; }; foreach ($benchmarks as $code => $callable) { $start = microtime(true); $collected = 0; while ($collected < $runs) { $collected++; $callable($array); } $end = microtime(true); printf('%s runs in %ss %s', $code, $end - $start, PHP_EOL); }

preferences:
33.84 ms | 402 KiB | 5 Q