3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$states = json_decode('[[[2,0,1],[1,1,0]],[[4,1],[3,0,1]]]'); $states = json_decode('[[[2,0,1],[1,1,0]],[[4,1,2],[3,0,1]],[[99,0],[99,0],[22,0],[33,1,2]]]'); $state = 0; $tape = array(1, 1, 1, 1, 0, 0, 0); if (substr(phpversion(), -5) == '-hhvm') { $updatesInternalPointer = true; $noticesPointerOnlyMutation = true; $rightEdgeBug = false; } elseif (substr(phpversion(), 0, 1) == 7) { $updatesInternalPointer = false; $noticesPointerOnlyMutation = true; $rightEdgeBug = false; } else { $updatesInternalPointer = true; $noticesPointerOnlyMutation = false; $rightEdgeBug = true; } if ($rightEdgeBug) $tape[] = 0; foreach ($tape as $k => &$v) { if (is_null($state)) break; @list ($v, $d, $state) = $states[$state][$v]; if ($d) { if (count($tape) - $k < ($rightEdgeBug ? 3 : 2)) $tape[] = 0; if (!$updatesInternalPointer) next($tape); } elseif ($k) { $lol = $tape; if ($noticesPointerOnlyMutation) { prev($tape); if ($updatesInternalPointer) prev($tape); } else { prev($lol); if ($updatesInternalPointer) prev($lol); $tape = $lol; } unset($lol); } else { array_unshift($tape, 0); if (!$updatesInternalPointer) { $lol = $tape; reset($tape); unset($lol); } } } unset($v); if ($rightEdgeBug) array_pop($tape); var_dump($tape);

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.60.0110.00316.73
7.2.00.0100.01019.30
7.1.100.0030.00718.35
7.1.70.0040.00417.23
7.1.60.0060.00617.37
7.1.50.0700.01032.71
7.1.40.0170.01332.52
7.1.30.0670.00732.50
7.1.20.0570.01332.70
7.1.10.0500.00714.63
7.1.00.0370.01014.54
7.0.200.0000.01016.52
7.0.190.0500.01014.61
7.0.180.0030.01014.32
7.0.170.0570.01314.38
7.0.160.0430.01014.32
7.0.150.0570.00314.35
7.0.140.0430.01314.30
7.0.130.0370.00714.67
7.0.120.0230.01714.68
7.0.110.0400.01314.56
7.0.100.0370.01314.61
7.0.90.0230.01014.21
7.0.80.0370.01314.65
7.0.70.0330.00714.44
7.0.60.0030.01314.14
7.0.50.0230.01314.54
7.0.40.0300.01014.62
7.0.30.0300.00714.61
7.0.20.0030.01014.41
7.0.10.0330.00714.45
7.0.00.0270.01014.67

preferences:
35.93 ms | 402 KiB | 5 Q