3v4l.org

run code in 300+ PHP versions simultaneously
<?php $iter = 0; function weight($array) { global $iter; $sum = array_sum($array); $rnd = mt_rand(0,$sum); foreach($array as $k=>$v) { $iter++; if($rnd <= $v) { return $k; } $rnd = $rnd - $v; } } $weights = range(0, 100000); $values = array_fill(0, count($weights), 0); for ($x = 0; $x < 1000; $x++) { $w = weight($weights); $values[$w] = $values[$w] + 1; } echo "$iter iterations performed"; var_dump($values);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.2.00.0072.42527.31
7.1.70.0032.36325.26
7.1.60.0132.25825.49
7.1.50.0132.26225.26
7.0.200.0132.23524.65

preferences:
48.56 ms | 401 KiB | 5 Q