3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = "turn off 499,499 through 500,500"; $lights = [[]]; for($i = 0; $i<1000; $i++){ for($j = 0; $j<1000; $j++){ $lights[$i][$j] = 0; } } $inputs = explode("\n",$input); function action($s){ $on = preg_match("/turn on/",$s); $off = preg_match("/turn off/",$s); $toggle = preg_match("/toggle/",$s); if($on > 0){ return 1; } else if($off>0){ return 2; } else if($toggle>0){ return 3; } } for($i = 0; $i < count($inputs); $i++){ $matches = null; preg_match_all("/\d{1,3},\d{1,3}/",$inputs[$i], $matches); $from = $matches[0][0]; $to = $matches[0][1]; $x1 = explode(",",$from)[0]; $y1 = explode(",",$from)[0]; $x2 = explode(",",$to)[0]; $y2 = explode(",",$to)[1]; for($j = $y1; $j<=$y2; $j++){ for($k = $x1; $k<=$x2; $k++){ if(action($inputs[$i])===1){ $lights[$j][$k] = 1; } else if(action($inputs[$i])===2){ $lights[$j][$k] = 0; } else if(action($inputs[$i])===3){ if($lights[$j][$k] === 0){ $lights[$j][$k] = 1; } else{ $lights[$j][$k] = 0; } } } } } $count = 0; for($i = 0; $i<1000; $i++){ for($j = 0; $j<1000; $j++){ if($lights[$i][$j] === 1){ $count++; } } } echo $count; ?>

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.70.0230.06532.79
8.3.60.0330.04332.75
8.3.50.0190.06634.84
8.3.40.0140.06834.71
8.3.30.0260.04934.67
8.3.20.0190.02236.55
8.3.10.0100.02740.62
8.3.00.0130.05038.05
8.2.180.0330.06032.63
8.2.170.0170.05734.71
8.2.160.0140.06436.32
8.2.150.0100.03035.21
8.2.140.0100.03038.30
8.2.130.0140.02836.40
8.2.120.0060.02939.86
8.2.110.0130.05736.84
8.2.100.0230.03733.80
8.2.90.0070.04334.92
8.2.80.0170.03433.63
8.2.70.0070.04333.63
8.2.60.0130.03633.80
8.2.50.0070.04333.50
8.2.40.0160.03237.43
8.2.30.0100.03936.42
8.2.20.0100.03833.42
8.2.10.0140.03533.84
8.2.00.0060.04633.79
8.1.280.0330.05948.23
8.1.270.0250.01146.14
8.1.260.0180.01149.65
8.1.250.0110.01847.59
8.1.240.0110.02550.55
8.1.230.0130.02944.69
8.1.220.0070.02643.61
8.1.210.0100.02343.23
8.1.200.0100.02443.23
8.1.190.0220.01143.11
8.1.180.0070.02743.30
8.1.170.0200.01344.46
8.1.160.0140.01846.51
8.1.150.0200.01344.45
8.1.140.0130.01945.17
8.1.130.0100.02143.31
8.1.120.0100.02143.14
8.1.110.0160.01643.23
8.1.100.0100.02243.27
8.1.90.0100.03043.25
8.1.80.0200.01343.28
8.1.70.0150.01843.09
8.1.60.0100.02743.41
8.1.50.0160.02243.22
8.1.40.0160.02343.33
8.1.30.0170.02043.30
8.1.20.0170.02043.27
8.1.10.0190.05248.95
8.1.00.0100.06149.01
8.0.300.0170.04048.22
8.0.290.0170.04048.13
8.0.280.0100.04349.79
8.0.270.0160.03948.55
8.0.260.0070.04749.74
8.0.250.0170.04048.30
8.0.240.0170.03848.08
8.0.230.0170.04048.34
8.0.220.0160.03848.20
8.0.210.0210.03448.25
8.0.200.0140.04148.19
8.0.190.0260.05548.21
8.0.180.0110.06048.21
8.0.170.0140.05848.24
8.0.160.0070.06448.32
8.0.150.0100.06148.22
8.0.140.0170.06848.13
8.0.130.0400.04744.78
8.0.120.0130.06048.11
8.0.110.0170.05348.05
8.0.100.0130.05748.05
8.0.90.0070.06448.11
8.0.80.0290.07748.10
8.0.70.0100.06148.19
8.0.60.0100.06148.19
8.0.50.0070.06448.01
8.0.30.0340.06948.26
8.0.20.0400.08048.32
8.0.10.0210.04848.15
8.0.00.0400.08147.99
7.4.330.0130.03650.04
7.4.320.0130.04347.75
7.4.300.0130.04247.76
7.4.290.0170.05747.76
7.4.280.0170.05847.84
7.4.270.0130.06147.74
7.4.260.0100.06347.80
7.4.250.0130.06347.79
7.4.240.0120.06347.71
7.4.230.0170.05847.60
7.4.220.0390.12647.87
7.4.210.0200.08947.86
7.4.200.0070.06847.66
7.4.160.0380.08347.78
7.4.150.0430.10747.86
7.4.140.0450.11847.94
7.4.130.0340.10347.89
7.4.120.0450.09747.81
7.4.110.0500.13247.96
7.4.100.0300.14647.93
7.4.90.0450.08747.71
7.4.80.0420.08447.71
7.4.70.0300.15147.69
7.4.60.0390.08747.85
7.4.50.0130.07747.81
7.4.40.0430.13347.77
7.4.30.0350.10347.88
7.4.10.0330.08946.42
7.4.00.0200.08546.16
7.3.330.0060.07344.79
7.3.320.0130.07544.45
7.3.310.0170.06347.84
7.3.300.0140.06047.75
7.3.290.0350.09847.87
7.3.280.0280.10647.86
7.3.270.0360.08948.00
7.3.260.0430.11048.01
7.3.250.0450.11347.99
7.3.240.0410.12147.91
7.3.230.0360.09147.78
7.3.210.0460.08547.84
7.3.200.0690.09647.83
7.3.190.0330.09847.92
7.3.180.0360.11247.98
7.3.170.0420.08747.97
7.3.160.0430.09547.81
7.3.130.0200.10546.34
7.3.120.0230.09446.34
7.3.110.0300.10046.25
7.3.100.0150.08146.26
7.3.90.0220.08446.41
7.3.80.0210.08046.21
7.3.70.0200.08146.25
7.3.60.0250.07646.30
7.3.50.0150.09046.16
7.3.40.0220.08346.22
7.3.30.0150.08945.88
7.3.20.0170.07652.63
7.3.10.0640.07352.28
7.3.00.0530.07052.46
7.2.330.0460.17548.14
7.2.320.0430.11248.15
7.2.310.0420.15648.27
7.2.300.0230.11348.11
7.2.290.0660.07948.19
7.2.260.0270.07646.80
7.2.250.0300.10046.36
7.2.240.0230.07346.63
7.2.230.0280.08446.65
7.2.220.0290.09346.65
7.2.210.0230.08946.40
7.2.200.0220.07846.46
7.2.190.0230.08146.41
7.2.180.0170.08546.30
7.2.170.0140.07946.31
7.2.160.0170.06846.62
7.2.150.0100.07452.76
7.2.140.0100.06652.86
7.2.130.0590.08052.63
7.2.120.0600.07752.71
7.2.110.0660.09052.64
7.2.100.0670.06352.79
7.2.90.0800.08452.68
7.2.80.0820.07252.66
7.2.70.0720.07752.69
7.2.60.0950.07452.72
7.2.50.0660.07352.77
7.2.40.0840.07952.73
7.2.30.0570.07652.75
7.2.20.0570.07552.59
7.2.10.0530.07752.70
7.2.00.0430.07053.25
7.1.330.0210.13951.54
7.1.320.0200.15751.71
7.1.310.0330.15051.73
7.1.300.0260.15551.76
7.1.290.0300.13751.65
7.1.280.1180.15351.72
7.1.270.0280.14951.64
7.1.260.0250.14351.65
7.1.250.0700.14651.67
7.1.240.0130.17651.73
7.1.230.0160.14151.71
7.1.220.0030.13751.75
7.1.210.0070.14951.78
7.1.200.0400.10851.52
7.1.190.0100.14151.84
7.1.180.0170.16951.61
7.1.170.0030.17551.76
7.1.160.0200.15451.71
7.1.150.0170.14551.74
7.1.140.0130.13351.48
7.1.130.0200.15051.85
7.1.120.0030.16751.62
7.1.110.0160.13251.41
7.1.100.8060.10552.71
7.1.90.0030.15151.66
7.1.80.0140.15651.68
7.1.70.0120.11452.46
7.1.60.0120.14452.32
7.1.50.0150.13052.12
7.1.40.0130.15651.98
7.1.30.0230.13851.93
7.1.20.0100.17451.75
7.1.10.0260.13251.79
7.1.00.0130.14554.92
7.0.330.0100.16451.39
7.0.320.0140.13951.48
7.0.310.0100.19351.39
7.0.300.0200.13951.15
7.0.290.0130.15651.36
7.0.280.0100.14951.20
7.0.270.0200.15151.49
7.0.260.0140.20351.27
7.0.250.0130.14651.19
7.0.240.0000.17951.60
7.0.230.0140.14851.23
7.0.220.0030.16151.42
7.0.210.0130.14951.38
7.0.200.0390.12550.03
7.0.190.0230.18451.43
7.0.180.0360.18051.44
7.0.170.0200.14651.45
7.0.160.0100.15651.48
7.0.150.0300.14951.14
7.0.140.0100.15351.40
7.0.130.0100.16351.57
7.0.120.0200.18351.18
7.0.110.0200.15151.25
7.0.100.0100.20151.41
7.0.90.0200.16451.28
7.0.80.0200.17351.15
7.0.70.0070.20051.33
7.0.60.0330.15051.51
7.0.50.0120.16050.03
7.0.40.0070.13216.91
7.0.30.0150.13116.85
7.0.20.0220.13716.98
7.0.10.0080.16916.96
7.0.00.0130.16016.92
5.6.400.0370.13879.41
5.6.390.0370.15679.38
5.6.380.0560.10979.31
5.6.370.0200.15678.93
5.6.360.0500.12779.38
5.6.350.0360.14878.97
5.6.340.0470.12279.38
5.6.330.0440.12979.31
5.6.320.0420.15579.53
5.6.310.0540.12479.53
5.6.300.0310.14178.93
5.6.290.0240.14579.18
5.6.280.0200.12182.42
5.6.270.0510.13879.09
5.6.260.0420.15779.25
5.6.250.0400.14178.97
5.6.240.0400.16079.15
5.6.230.0400.12678.98
5.6.220.0330.14978.95
5.6.210.0250.16082.30
5.6.200.0330.13480.77
5.6.190.0270.15582.03
5.6.180.0410.13982.00
5.6.170.0330.14282.01
5.6.160.0430.14882.20
5.6.150.0370.11080.89
5.6.140.0280.14880.96
5.6.130.0370.14081.08
5.6.120.0310.11982.49
5.6.110.0420.15382.42
5.6.100.0370.16382.32
5.6.90.0280.12882.35
5.6.80.0330.14382.13
5.6.70.0300.12579.02
5.6.60.0330.14578.77
5.6.50.0270.12778.77
5.6.40.0200.13179.06
5.6.30.0200.16078.96
5.6.20.0400.17279.05
5.6.10.0470.12378.95
5.6.00.0300.15878.80
5.5.380.0440.11478.80
5.5.370.0270.16178.76
5.5.360.0540.14579.25
5.5.350.0400.14882.27
5.5.340.0250.14580.95
5.5.330.0170.13581.82
5.5.320.0520.14382.01
5.5.310.0230.14582.11
5.5.300.0430.14380.69
5.5.290.0230.12380.68
5.5.280.0280.16782.24
5.5.270.0360.12382.23
5.5.260.0330.14782.38
5.5.250.0370.14882.19
5.5.240.0350.11682.00
5.5.230.0300.15479.07
5.5.220.0200.14678.85
5.5.210.0200.13579.15
5.5.200.0270.15479.00
5.5.190.0600.15479.02
5.5.180.0370.13778.71
5.5.170.0360.12679.13
5.5.160.0200.15478.92
5.5.150.0270.12679.09
5.5.140.0330.11779.23
5.5.130.0640.12479.01
5.5.120.0230.14979.08
5.5.110.0330.13678.90
5.5.100.0170.13978.73
5.5.90.0230.16678.76
5.5.80.0470.15478.76
5.5.70.0470.13878.77
5.5.60.0340.12478.98
5.5.50.0230.16478.97
5.5.40.0230.15779.02
5.5.30.0200.16878.70
5.5.20.0330.14779.06
5.5.10.0230.14278.89
5.5.00.0560.11978.86

preferences:
57.98 ms | 401 KiB | 5 Q