3v4l.org

run code in 300+ PHP versions simultaneously
<?php $lizards = []; for ($i = 0; $i < 15; $i++) { $lizards[] = 1; } for ($i = 0; $i < 7; $i++) { $lizards[] = 2; } for ($i = 0; $i < 8; $i++) { $lizards[] = 3; } srand(time()); for ($i = 0; $i < 10000; $i++) { $a1 = mt_rand(0, count($lizards) - 1); do { $a2 = mt_rand(0, count($lizards) - 1); } while ($a1 == $a2); if ($lizards[$a1] == $lizards[$a2]) { continue; } $new_color = 6 - $lizards[$a1] - $lizards[$a2]; $lizards[$a1] = $new_color; $lizards[$a2] = $new_color; $colors_count = (in_array(1, $lizards) ? 1 : 0) + (in_array(2, $lizards) ? 1 : 0) + (in_array(3, $lizards) ? 1 : 0); if ($colors_count == 1) { echo "Остался только один цвет\n"; break; } $counts = [null, 0, 0, 0]; foreach ($lizards as $color) { $counts[$color]++; } echo sprintf("%s\t%s\t%s\n", $counts[1], $counts[2], $counts[3]); } ?>

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.3.10.0780.02514.55
7.3.00.0960.02114.94
7.2.130.0940.02014.93
7.2.120.0900.01714.98
7.2.110.0790.01315.16
7.2.100.1000.02914.74
7.2.90.0930.03315.13
7.2.80.0750.01014.89
7.2.70.0930.01714.62
7.2.60.1210.02414.89
7.2.50.0670.02614.97
7.2.40.0910.02615.13
7.2.30.0800.00715.05
7.2.20.1240.02315.07
7.2.10.0710.01615.00
7.2.00.0840.02015.30
7.1.250.1170.01413.64

preferences:
37.41 ms | 403 KiB | 5 Q