3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sInput = 'toggle 0,0 through 999,0'; $aLights = array(); for($x = 0; $x < 1000; $x++) { for($y = 0; $y < 1000; $y++) { $aLights[$x . 'x' . $y] = false; } } $aInput = explode("\r\n", $sInput); foreach($aInput as $sInput) { preg_match('#(?<action>turn (?:on|off)|toggle) (?<from_x>[0-9]{1,3}),(?<from_y>[0-9]{1,3}) through (?<to_x>[0-9]{1,3}),(?<to_y>[0-9]{1,3})#', $sInput, $aMatch); for($x = $aMatch['from_x']; $x <= $aMatch['to_x']; $x++) { for($y = $aMatch['from_y']; $y <= $aMatch['to_y']; $y++) { switch($aMatch['action']) { case 'turn on': $aLights[$x . 'x' . $y] = true; break; case 'turn off': $aLights[$x . 'x' . $y] = false; break; case 'toggle': $aLights[$x . 'x' . $y] = ($aLights[$x . 'x' . $y] ? false : true); break; } } } } echo count(array_filter($aLights));

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)
8.3.60.0440.09852.60
8.3.50.0500.10352.45
8.3.40.0240.04737.12
8.3.30.0270.04737.06
8.3.20.0130.02638.52
8.3.10.0170.04040.22
8.3.00.0070.02338.07
8.2.180.0590.07952.75
8.2.170.0340.05437.08
8.2.160.0340.06038.36
8.2.150.0350.03937.27
8.2.140.0130.02338.72
8.2.130.0130.02937.36
8.2.120.0070.02337.74
8.2.110.0100.03038.73
8.2.100.0310.02736.08
8.2.90.0170.03137.27
8.2.80.0070.04135.68
8.2.70.0130.03735.58
8.2.60.0100.03936.10
8.2.50.0200.02935.55
8.2.40.0100.03438.88
8.2.30.0130.03338.59
8.2.20.0000.04635.52
8.2.10.0160.02935.93
8.2.00.0090.03535.96
8.1.280.0580.07552.28
8.1.270.0180.05638.75
8.1.260.0230.01740.40
8.1.250.0200.04638.70
8.1.240.0130.03040.49
8.1.230.0400.03037.15
8.1.220.0070.04035.80
8.1.210.0230.03035.39
8.1.200.0130.03335.43
8.1.190.0070.03735.39
8.1.180.0170.03335.59
8.1.170.0100.03536.54
8.1.160.0160.02938.68
8.1.150.0200.02736.68
8.1.140.0110.03537.45
8.1.130.0100.03835.52
8.1.120.0060.03935.27
8.1.110.0070.03935.22
8.1.100.0060.03935.32
8.1.90.0070.04035.27
8.1.80.0140.03435.31
8.1.70.0130.03335.22
8.1.60.0140.03435.41
8.1.50.0070.04335.27
8.1.40.0100.03835.28
8.1.30.0100.03935.47
8.1.20.0030.05035.42
8.1.10.0260.06653.47
8.1.00.0170.07553.48
8.0.300.0140.07152.83
8.0.290.0190.06852.59
8.0.280.0200.06654.25
8.0.270.0130.07253.07
8.0.260.0240.06453.20
8.0.250.0170.07052.78
8.0.240.0100.07852.76
8.0.230.0210.06652.67
8.0.220.0200.06852.55
8.0.210.0270.06052.61
8.0.200.0170.07252.82
8.0.190.0420.07852.62
8.0.180.0260.06952.78
8.0.170.0330.06352.60
8.0.160.0170.07752.60
8.0.150.0170.07552.59
8.0.140.0230.06752.50
8.0.130.0570.19482.55
8.0.120.0200.07452.64
8.0.110.0100.08152.53
8.0.100.0270.06552.53
8.0.90.0370.07552.59
8.0.80.0600.19552.65
8.0.70.0200.07252.77
8.0.60.0360.05652.54
8.0.50.0240.07152.66
8.0.30.0490.13752.87
8.0.20.0570.12452.83
8.0.10.0140.07552.59
8.0.00.0620.12652.65
7.4.330.0000.07251.33
7.4.320.0230.06952.37
7.4.300.0270.06752.27
7.4.290.0260.06852.25
7.4.280.0170.07752.24
7.4.270.0270.06552.36
7.4.260.0170.07452.35
7.4.250.0270.06752.36
7.4.240.0170.07452.34
7.4.230.0200.07052.26
7.4.220.0500.13952.34
7.4.210.0460.11252.18
7.4.200.0200.07052.26
7.4.160.0520.16452.11
7.4.150.0560.15752.13
7.4.140.0620.13452.29
7.4.130.0640.13752.38
7.4.120.0490.14352.30
7.4.110.0650.12852.27
7.4.100.0520.17052.43
7.4.90.0550.13552.29
7.4.80.0810.19052.29
7.4.70.0640.14252.15
7.4.60.0560.12552.19
7.4.50.0400.14052.21
7.4.40.0620.13652.43
7.4.30.0960.17952.25
7.4.00.0370.13650.52
7.3.330.0370.13682.45
7.3.320.0470.13082.49
7.3.310.0290.07152.07
7.3.300.0200.07452.06
7.3.290.0500.14852.03
7.3.280.0510.16052.06
7.3.270.0640.12652.29
7.3.260.0670.13352.05
7.3.250.0700.12952.24
7.3.240.0520.13852.19
7.3.230.0730.19952.32
7.3.210.0560.13052.10
7.3.200.0580.13052.01
7.3.190.0400.14652.23
7.3.180.0630.17552.23
7.3.170.0490.13551.90
7.3.160.0620.20852.16
7.3.120.0430.17550.55
7.3.110.0360.14950.93
7.3.100.0300.11350.49
7.3.90.0230.14050.53
7.3.80.0300.13350.50
7.3.70.0100.14850.64
7.3.60.0440.12150.62
7.3.50.0170.17750.52
7.3.40.0330.16050.28
7.3.30.0400.12950.79
7.3.20.0100.13552.39
7.3.10.0440.14452.43
7.3.00.0070.11552.49
7.2.330.0530.21550.30
7.2.320.0740.19750.01
7.2.310.0670.15050.41
7.2.300.0620.14750.30
7.2.290.0480.14750.04
7.2.250.0230.13848.66
7.2.240.0330.14948.65
7.2.230.0290.14148.96
7.2.220.0330.11949.04
7.2.210.0260.14248.91
7.2.200.0170.12848.52
7.2.190.0200.20448.71
7.2.180.0270.17148.49
7.2.170.0330.13248.79
7.2.60.1200.09750.87
7.2.00.0170.08353.39
7.1.330.0200.15149.62
7.1.320.0790.15449.55
7.1.310.0270.18749.65
7.1.300.0160.14149.73
7.1.290.0650.14749.79
7.1.280.0160.15149.48
7.1.270.0400.19349.58
7.1.260.0360.16549.67
7.1.200.0870.09349.69
7.1.100.0270.11451.95
7.1.70.0100.08551.07
7.1.60.0300.07751.18
7.1.50.0200.12751.16
7.1.00.0130.17756.21
7.0.200.1300.11448.73
7.0.60.0500.16053.67
7.0.50.0400.08751.55
7.0.40.0300.12737.44
7.0.30.0800.14037.42
7.0.20.1000.15037.69
7.0.10.0070.12737.41
7.0.00.0100.17737.56
5.6.280.0100.27085.60
5.6.210.0500.21785.22
5.6.200.0170.23082.79
5.6.190.0330.19085.11
5.6.180.0670.20784.94
5.6.170.0430.20785.00
5.6.160.0330.19084.71
5.6.150.0430.19382.75
5.6.140.0330.24382.79
5.6.130.0300.19782.75
5.6.120.0330.18385.61
5.6.110.0330.25785.63
5.6.100.0370.19785.70
5.6.90.0470.23785.61
5.6.80.0500.20385.00
5.5.350.0470.18385.02
5.5.340.0170.19382.54
5.5.330.0300.18384.77
5.5.320.0770.19784.81
5.5.310.0270.22784.80
5.5.300.0330.24382.59
5.5.290.0330.24782.57
5.5.280.0230.25385.58
5.5.270.0130.22085.57
5.5.260.0200.19085.27
5.5.250.0200.26085.19
5.5.240.0430.24784.98

preferences:
48.78 ms | 400 KiB | 5 Q