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]; $to = $matches[1]; $x1 = explode(",",$from)[0][0]; $y1 = explode(",",$from)[0][1]; $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.130.0100.03032.53
8.3.120.0130.03737.54
8.3.110.0120.01832.80
8.3.100.0160.01335.97
8.3.90.0070.01735.62
8.3.80.0210.02133.03
8.3.70.0430.02032.38
8.3.60.0270.04432.84
8.3.50.0350.03033.85
8.3.40.0230.04734.54
8.3.30.0230.02934.67
8.3.20.0070.03135.91
8.3.10.0160.02239.29
8.3.00.0040.01937.72
8.2.250.0170.01332.79
8.2.240.0070.02133.86
8.2.230.0200.03632.50
8.2.220.0170.01432.67
8.2.210.0160.01334.17
8.2.200.0140.02134.65
8.2.190.0370.02734.21
8.2.180.0400.01332.38
8.2.170.0100.04034.71
8.2.160.0310.03836.10
8.2.150.0300.00034.64
8.2.140.0160.01336.74
8.2.130.0070.02435.02
8.2.120.0070.01539.74
8.2.110.0210.02136.40
8.2.100.0230.01633.68
8.2.90.0070.02634.80
8.2.80.0130.02033.63
8.2.70.0030.02933.50
8.2.60.0000.03133.55
8.2.50.0090.02233.75
8.2.40.0120.01938.21
8.2.30.0100.02036.58
8.2.20.0140.01733.45
8.2.10.0100.02033.82
8.2.00.0110.02133.85
8.1.300.0190.02248.00
8.1.290.0260.01349.27
8.1.280.0470.04748.84
8.1.270.0130.02646.26
8.1.260.0170.01448.98
8.1.250.0140.01747.05
8.1.240.0170.02149.69
8.1.230.0220.02243.83
8.1.220.0030.03143.41
8.1.210.0060.02642.98
8.1.200.0120.02343.13
8.1.190.0160.01643.25
8.1.180.0030.02943.41
8.1.170.0100.02344.30
8.1.160.0060.02546.32
8.1.150.0070.02444.57
8.1.140.0130.02045.32
8.1.130.0170.01443.38
8.1.120.0100.02143.27
8.1.110.0130.02043.26
8.1.100.0030.02943.25
8.1.90.0220.01943.23
8.1.80.0160.01943.20
8.1.70.0130.01943.05
8.1.60.0140.02443.33
8.1.50.0200.01743.32
8.1.40.0070.03043.33
8.1.30.0070.03043.35
8.1.20.0030.03443.28
8.1.10.0130.03048.95
8.1.00.0130.03048.96
8.0.300.0030.03548.32
8.0.290.0130.02648.13
8.0.280.0100.02649.79
8.0.270.0030.03348.60
8.0.260.0260.01048.56
8.0.250.0130.02448.25
8.0.240.0170.02048.29
8.0.230.0160.02248.21
8.0.220.0170.02048.22
8.0.210.0040.03248.18
8.0.200.0190.01648.16
8.0.190.0230.02348.31
8.0.180.0170.02448.27
8.0.170.0100.03248.25
8.0.160.0200.02348.24
8.0.150.0170.02448.07
8.0.140.0160.02648.10
8.0.130.0260.02944.63
8.0.120.0130.03048.05
8.0.110.0100.03148.16
8.0.100.0190.02248.11
8.0.90.0000.04148.00
8.0.80.0270.05048.14
8.0.70.0190.02248.05
8.0.60.0190.02348.10
8.0.50.0030.03748.21
8.0.30.0370.04048.47
8.0.20.0410.05848.38
8.0.10.0070.03348.37
8.0.00.0420.04948.15
7.4.330.0100.03850.07
7.4.320.0070.04847.86
7.4.300.0030.05247.77
7.4.290.0200.05647.83
7.4.280.0160.06247.66
7.4.270.0130.06247.86
7.4.260.0170.05747.85
7.4.250.0160.06147.71
7.4.240.0100.06647.80
7.4.230.0070.06847.89
7.4.220.0440.08447.91
7.4.210.0440.06747.80
7.4.200.0240.05147.80
7.4.160.0330.08747.83
7.4.150.0490.09548.01
7.4.140.0290.09847.88
7.4.130.0520.09747.80
7.4.120.0320.09047.84
7.4.110.0500.08747.83
7.4.100.0200.10547.82
7.4.90.0320.09347.85
7.4.80.0400.09347.79
7.4.70.0390.15047.80
7.4.60.0300.09247.95
7.4.50.0230.06447.63
7.4.40.0390.08647.85
7.4.30.0360.13947.83
7.4.00.0170.08646.15
7.3.330.0130.07144.81
7.3.320.0200.07144.90
7.3.310.0130.06647.64
7.3.300.0200.05647.71
7.3.290.0420.09447.89
7.3.280.0390.11747.83
7.3.270.0160.10848.07
7.3.260.0300.10147.83
7.3.250.0430.10647.90
7.3.240.0390.10347.81
7.3.230.0390.09247.79
7.3.210.0500.07647.76
7.3.200.0490.10447.84
7.3.190.0410.09448.08
7.3.180.0360.09547.84
7.3.170.0530.08448.09
7.3.160.0580.13847.78
7.3.120.0300.06746.31
7.3.110.0070.09046.11
7.3.100.0230.09546.16
7.3.90.0200.06946.42
7.3.80.0270.06846.23
7.3.70.0260.07646.28
7.3.60.0130.07046.37
7.3.50.0270.09646.38
7.3.40.0240.09846.25
7.3.30.0160.08546.26
7.3.20.0290.09352.22
7.3.10.0230.09152.63
7.3.00.0330.05952.84
7.2.330.0420.11448.30
7.2.320.0360.14248.16
7.2.310.0400.15448.14
7.2.300.0370.11848.13
7.2.290.0460.08548.26
7.2.250.0200.10546.68
7.2.240.0200.09246.58
7.2.230.0230.09946.78
7.2.220.0230.10646.31
7.2.210.0170.08446.54
7.2.200.0100.10646.63
7.2.190.0200.06446.69
7.2.180.0460.06946.36
7.2.170.0170.10246.32
7.2.80.0570.06752.58
7.2.60.1830.05252.70
7.2.00.0240.07855.42
7.1.330.0030.14851.78
7.1.320.0030.16251.77
7.1.310.0000.15851.83
7.1.300.0130.14951.52
7.1.290.0360.16751.75
7.1.280.0100.18451.84
7.1.270.0130.16851.54
7.1.260.0170.15851.23
7.1.200.0790.06851.46
7.1.100.7930.08749.57
7.1.70.0130.07053.13
7.1.60.0100.06652.76
7.1.50.0130.09652.54
7.1.00.0130.15058.27
7.0.200.3420.07648.94
7.0.60.0200.13351.28
7.0.50.0200.15349.30
7.0.40.0070.10320.28
7.0.30.0300.12720.23
7.0.20.0400.11320.09
7.0.10.0170.11020.28
7.0.00.0170.13320.24
5.6.210.0400.13085.23
5.6.200.0330.15782.88
5.6.190.0230.15385.07
5.6.180.0400.10085.09
5.6.170.0370.14084.89
5.6.160.0230.11385.05
5.6.150.0130.11082.86
5.6.140.0200.17082.93
5.6.130.0130.13082.83
5.6.120.0430.14785.71
5.6.110.0400.15385.67
5.6.100.0170.11385.70
5.6.90.0300.17085.70
5.6.80.0400.11785.26
5.5.350.0400.14085.05
5.5.340.0330.16082.52
5.5.330.0170.12384.75
5.5.320.0600.15084.89
5.5.310.0330.12384.93
5.5.300.0400.16082.71
5.5.290.0230.16382.71
5.5.280.0500.15385.61
5.5.270.0270.13385.69
5.5.260.0370.14785.37
5.5.250.0170.17085.51
5.5.240.0330.12084.91

preferences:
27.92 ms | 403 KiB | 5 Q