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.60.0270.07732.63
8.3.50.0180.06534.47
8.3.40.0260.07234.81
8.3.30.0310.04434.85
8.3.20.0130.04936.58
8.3.10.0040.03241.45
8.3.00.0100.02637.64
8.2.180.0370.06733.86
8.2.170.0230.05034.94
8.2.160.0400.05036.07
8.2.150.0210.04535.52
8.2.140.0030.03438.52
8.2.130.0130.02636.38
8.2.120.0130.05339.86
8.2.110.0230.08136.77
8.2.100.0160.04333.79
8.2.90.0070.04434.88
8.2.80.0100.04433.63
8.2.70.0200.03033.50
8.2.60.0100.04233.91
8.2.50.0100.04133.88
8.2.40.0090.03838.46
8.2.30.0140.03536.39
8.2.20.0000.04933.42
8.2.10.0170.03333.82
8.2.00.0030.04733.93
8.1.280.0370.08548.43
8.1.270.0330.00746.07
8.1.260.0290.02949.39
8.1.250.0130.01647.64
8.1.240.0170.02050.54
8.1.230.0320.01344.55
8.1.220.0100.02343.51
8.1.210.0070.02543.23
8.1.200.0070.02743.10
8.1.190.0070.02543.10
8.1.180.0070.02543.28
8.1.170.0200.01344.41
8.1.160.0100.02346.43
8.1.150.0130.01944.56
8.1.140.0040.02845.26
8.1.130.0130.02043.42
8.1.120.0040.02843.28
8.1.110.0100.02143.18
8.1.100.0160.01643.15
8.1.90.0130.02743.18
8.1.80.0140.01743.24
8.1.70.0070.02443.04
8.1.60.0120.02543.23
8.1.50.0130.02343.30
8.1.40.0130.02343.30
8.1.30.0130.02343.26
8.1.20.0000.03743.29
8.1.10.0170.05648.92
8.1.00.0100.06148.96
8.0.300.0200.03648.29
8.0.290.0040.05348.25
8.0.280.0100.04349.78
8.0.270.0170.04048.46
8.0.260.0240.03148.55
8.0.250.0100.04548.21
8.0.240.0130.04348.21
8.0.230.0100.04648.23
8.0.220.0100.04648.20
8.0.210.0200.03648.24
8.0.200.0030.05148.30
8.0.190.0200.06048.32
8.0.180.0130.05948.24
8.0.170.0100.06348.30
8.0.160.0100.06348.31
8.0.150.0130.06048.18
8.0.140.0200.06348.09
8.0.130.0200.05944.73
8.0.120.0160.05548.20
8.0.110.0230.04848.11
8.0.100.0100.06148.17
8.0.90.0130.05748.18
8.0.80.0350.08148.17
8.0.70.0030.06748.26
8.0.60.0130.05948.18
8.0.50.0100.06048.11
8.0.30.0290.07048.21
8.0.20.0350.08548.23
8.0.10.0230.04948.15
8.0.00.0360.10948.10
7.4.330.0030.04550.52
7.4.320.0160.04047.69
7.4.300.0130.04347.92
7.4.290.0170.05747.79
7.4.280.0130.06347.71
7.4.270.0130.06047.81
7.4.260.0210.05547.80
7.4.250.0130.06247.86
7.4.240.0130.06047.81
7.4.230.0100.06547.64
7.4.220.0230.09747.80
7.4.210.0130.10047.77
7.4.200.0130.06047.64
7.4.160.0330.08547.80
7.4.150.0340.09148.02
7.4.140.0590.12447.84
7.4.130.0370.09947.72
7.4.120.0360.09447.82
7.4.110.0360.10547.65
7.4.100.0660.11547.84
7.4.90.0480.08447.81
7.4.80.0430.09047.92
7.4.70.0400.12147.76
7.4.60.0400.13647.86
7.4.50.0240.06847.74
7.4.40.0330.09747.85
7.4.30.0430.08447.86
7.4.00.0160.06646.14
7.3.330.0060.08445.00
7.3.320.0060.08144.84
7.3.310.0130.06547.89
7.3.300.0210.05547.84
7.3.290.0320.10647.89
7.3.280.0330.10547.93
7.3.270.0360.09347.80
7.3.260.0350.11048.10
7.3.250.0340.10147.83
7.3.240.0360.09548.04
7.3.230.0440.08247.77
7.3.210.0330.10647.81
7.3.200.0430.08748.02
7.3.190.0450.09148.05
7.3.180.0470.08548.05
7.3.170.0400.15148.19
7.3.160.0390.10047.97
7.3.00.2300.06648.55
7.2.330.0600.07948.31
7.2.320.0470.10748.16
7.2.310.0550.14148.18
7.2.300.0420.10248.12
7.2.290.0260.10648.08
7.2.130.1490.07847.90
7.2.120.0740.06748.53
7.2.110.2070.07552.50
7.2.100.0200.08952.48
7.2.90.0100.07052.93
7.2.80.0740.06452.41
7.2.70.0030.08652.75
7.2.60.0500.08152.50
7.2.50.0040.09152.69
7.2.40.0140.08652.86
7.2.30.0230.08852.62
7.2.20.0070.10052.73
7.2.10.0260.06852.44
7.2.00.0140.06754.16
7.1.250.0860.15649.30
7.1.240.3960.14650.70
7.1.230.3590.16051.49
7.1.220.1060.14951.37
7.1.210.1320.16551.61
7.1.200.1200.12251.68
7.1.190.0100.15051.26
7.1.180.0100.16251.66
7.1.170.0060.17451.52
7.1.160.0040.15851.75
7.1.150.0100.16851.59
7.1.140.0100.16151.54
7.1.130.0290.13651.67
7.1.120.0140.14951.67
7.1.110.0230.13951.63
7.1.100.1090.11952.59
7.1.90.0140.15951.72
7.1.80.0240.13251.91
7.1.70.0170.11952.48
7.1.60.0080.11352.43
7.1.50.0170.12752.21
7.1.40.0100.14351.62
7.1.30.0130.13851.80
7.1.20.0100.16051.48
7.1.10.0100.16051.61
7.1.00.0120.15154.89
7.0.330.1070.16048.84
7.0.320.0190.14851.36
7.0.310.0130.16051.13
7.0.300.0100.18651.40
7.0.290.0100.16751.35
7.0.280.0100.14551.57
7.0.270.0130.15251.40
7.0.260.0170.15851.30
7.0.250.0200.16251.31
7.0.240.0200.14551.37
7.0.230.0290.14251.21
7.0.220.0190.14551.43
7.0.210.0230.14351.64
7.0.200.0460.11750.06
7.0.190.0130.15551.41
7.0.180.0030.16651.54
7.0.170.1010.15051.55
7.0.160.1000.15651.40
7.0.150.0160.15151.36
7.0.140.0160.15251.52
7.0.130.0250.14551.52
7.0.120.0100.15751.51
7.0.110.0070.18351.36
7.0.100.0160.16751.52
7.0.90.0170.16451.18
7.0.80.0030.17151.23
7.0.70.0130.16651.45
7.0.60.0120.15951.27
7.0.50.0170.14050.22
7.0.40.0130.14316.86
7.0.30.0260.13516.97
7.0.20.0250.13316.97
7.0.10.0150.14516.92
7.0.00.0050.13516.87
5.6.380.0280.12478.83
5.6.370.0240.13178.94
5.6.360.0350.13279.06
5.6.350.0280.14478.96
5.6.340.0200.16879.20
5.6.330.0330.12379.09
5.6.320.0340.12679.32
5.6.310.0420.12478.75
5.6.300.0270.14379.00
5.6.290.0270.14178.99
5.6.280.0300.11582.13
5.6.270.0340.13978.99
5.6.260.0400.14879.28
5.6.250.0210.14378.86
5.6.240.0310.14679.04
5.6.230.0400.12379.04
5.6.220.0560.11179.12
5.6.210.0220.15882.12
5.6.200.0360.14180.95
5.6.190.0290.14682.12
5.6.180.0380.12181.90
5.6.170.0310.14781.93
5.6.160.0320.14082.09
5.6.150.0370.14280.92
5.6.140.0290.11680.89
5.6.130.0320.15080.80
5.6.120.0340.15182.28
5.6.110.0340.14282.43
5.6.100.0430.13482.38
5.6.90.0380.15282.40
5.6.80.0430.11681.95
5.6.70.0280.14478.63
5.6.60.0330.13478.70
5.6.50.0340.14479.01
5.6.40.0330.13579.15
5.6.30.0500.11478.98
5.6.20.0490.11878.77
5.6.10.0400.12179.10
5.6.00.0520.12078.83
5.5.380.0230.13775.87
5.5.370.0330.13276.14
5.5.360.0480.11275.96
5.5.350.0390.15080.50
5.5.340.0350.13979.28
5.5.330.0200.13380.40
5.5.320.0560.12680.37
5.5.310.0440.11280.41
5.5.300.0230.13279.38
5.5.290.0320.13979.33
5.5.280.0380.13580.75
5.5.270.0320.15380.78
5.5.260.0370.14580.70
5.5.250.0470.12980.64
5.5.240.0330.15280.32
5.5.230.0290.12775.90
5.5.220.0270.14475.99
5.5.210.0200.14275.77
5.5.200.0260.13575.88
5.5.190.0340.13475.61
5.5.180.0460.12575.92
5.5.170.0430.12975.79
5.5.160.0300.13475.89
5.5.150.0300.12575.71
5.5.140.0360.12375.61
5.5.130.0330.13275.34
5.5.120.0270.13575.90
5.5.110.0450.13075.65
5.5.100.0170.14675.73
5.5.90.0400.13475.88
5.5.80.0130.14775.47
5.5.70.0240.13475.54
5.5.60.0270.13975.63
5.5.50.0230.14375.73
5.5.40.0530.10675.73
5.5.30.0210.14075.82
5.5.20.0560.10975.59
5.5.10.0330.14075.63
5.5.00.0240.14375.89

preferences:
56.63 ms | 401 KiB | 5 Q