3v4l.org

run code in 300+ PHP versions simultaneously
<?php $parents = [1 => 0, 2 => 1, 3 => 2]; $cache = [1 => 5, 2 => 4, 3 => 3]; function count_posts($category_id, $parents, $cache) { $sum = 0; foreach ($parents as $child) { $sum += count_posts($child, $parents, $child); } $sum += $cache[$category_id]; return $sum; } count_posts(1, $parents, $cache);

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.0620.01673.27
8.3.50.0780.01673.50
8.3.40.0260.01344.63
8.3.30.0290.01044.63
8.3.20.0260.00646.16
8.3.10.0160.00346.38
8.3.00.0130.00746.80
8.2.180.0390.02673.36
8.2.170.0330.01644.91
8.2.160.0230.01646.53
8.2.150.0190.00344.82
8.2.140.0160.00346.41
8.2.130.0090.00945.71
8.2.120.0190.00444.03
8.2.110.0180.01445.39
8.2.100.0230.00843.91
8.2.90.0100.01045.22
8.2.80.0130.01343.50
8.2.70.0130.00743.50
8.2.60.0190.00443.80
8.2.50.0190.00943.50
8.2.40.0230.00346.49
8.2.30.0100.01045.36
8.2.20.0170.00743.50
8.2.10.0210.00343.86
8.2.00.0220.00043.84
8.1.280.0330.01376.74
8.1.270.0070.00751.42
8.1.260.0210.01145.77
8.1.250.0160.00748.25
8.1.240.0170.00749.45
8.1.230.0240.00743.64
8.1.220.0160.00443.66
8.1.210.0100.01343.36
8.1.200.0150.00843.35
8.1.190.0210.00043.25
8.1.180.0190.00343.35
8.1.170.0130.00744.83
8.1.160.0130.00746.84
8.1.150.0130.00744.82
8.1.140.0100.01045.59
8.1.130.0180.00443.75
8.1.120.0160.00643.52
8.1.110.0130.01043.42
8.1.100.0120.00643.46
8.1.90.0140.00743.41
8.1.80.0130.00643.48
8.1.70.0130.00743.50
8.1.60.0110.01443.70
8.1.50.0170.00743.53
8.1.40.0200.00743.48
8.1.30.0150.00943.63
8.1.20.0160.00643.66
8.1.10.0170.02073.15
8.1.00.0210.02173.10
8.0.300.0160.01672.61
8.0.290.0250.00672.50
8.0.280.0290.00774.04
8.0.270.0330.00772.86
8.0.260.0180.01172.84
8.0.250.0250.01472.57
8.0.240.0230.01372.49
8.0.230.0280.00372.36
8.0.220.0190.01372.40
8.0.210.0340.01472.40
8.0.200.0200.01772.59
8.0.190.0230.01972.57
8.0.180.0430.00372.39
8.0.170.0410.00772.52
8.0.160.0160.02272.39
8.0.150.0290.01072.33
8.0.140.0330.00772.36
8.0.130.0360.039121.80
8.0.120.0170.02372.42
8.0.110.0230.01372.44
8.0.100.0230.01672.30
8.0.90.0320.00372.32
8.0.80.0470.03072.38
8.0.70.0160.01672.27
8.0.60.0190.01672.48
8.0.50.0270.01072.30
8.0.30.0470.03772.69
8.0.20.0540.03972.65
8.0.10.0170.01772.54
8.0.00.0590.03372.23
7.4.330.0260.00771.43
7.4.320.0230.00771.95
7.4.300.0360.01372.13
7.4.290.0270.01371.97
7.4.280.0300.01072.11
7.4.270.0200.01772.14
7.4.260.0270.01071.98
7.4.250.0270.01071.97
7.4.240.0110.02572.04
7.4.230.0260.01372.23
7.4.220.0620.03372.04
7.4.210.0420.02972.14
7.4.200.0310.00772.14
7.4.160.0480.03272.22
7.4.150.0400.04471.98
7.4.140.0660.03072.11
7.4.130.0640.03072.03
7.4.120.0590.02872.10
7.4.110.0450.03972.21
7.4.100.0540.06072.17
7.4.90.0590.03072.05
7.4.80.0590.03372.13
7.4.70.0760.02071.95
7.4.60.0580.02671.89
7.4.50.0200.03372.13
7.4.40.0520.02972.24
7.4.30.0600.02371.94
7.4.10.0330.04272.15
7.4.00.0400.02671.34
7.3.330.0630.017121.87
7.3.320.0330.023121.79
7.3.310.0230.01371.72
7.3.300.0350.00471.71
7.3.290.0840.02571.85
7.3.280.0490.03371.84
7.3.270.0530.02771.96
7.3.260.0860.03071.95
7.3.250.0590.02871.98
7.3.240.0580.03071.93
7.3.230.0710.03672.01
7.3.210.0530.03371.84
7.3.200.0670.03872.08
7.3.190.0660.02371.97
7.3.180.0420.03971.93
7.3.170.0610.03071.91
7.3.160.0630.01771.84
7.3.130.0380.03471.70
7.3.120.0350.02672.20
7.3.110.0290.02271.93
7.3.100.0310.03772.02
7.3.90.0440.01471.80
7.3.80.0240.02471.80
7.3.70.0290.02671.94
7.3.60.0280.01971.98
7.3.50.0260.02371.99
7.3.40.0240.02771.74
7.3.30.0230.02772.07
7.3.20.0100.02079.97
7.3.10.0420.01679.09
7.3.00.0230.02579.14
7.2.330.0570.03671.86
7.2.320.0870.02071.95
7.2.310.0490.04971.92
7.2.300.0590.02971.93
7.2.290.0550.04571.89
7.2.260.0400.03371.85
7.2.250.0360.02071.83
7.2.240.0330.02672.19
7.2.230.0400.02772.08
7.2.220.0260.02371.97
7.2.210.0370.01771.79
7.2.200.0200.03372.00
7.2.190.0210.04271.85
7.2.180.0330.02372.08
7.2.170.0260.02671.85
7.2.160.0210.03172.16
7.2.150.0200.02080.16
7.2.140.0070.02780.27
7.2.130.0400.02479.12
7.2.120.0770.01979.11
7.2.110.0860.02178.99
7.2.100.0900.02379.14
7.2.90.0840.02679.16
7.2.80.1000.02879.02
7.2.70.1240.03179.17
7.2.60.1750.02179.18
7.2.50.0940.01879.15
7.2.40.0470.02779.28
7.2.30.1090.01879.24
7.2.20.0510.02579.14
7.2.10.0840.02579.19
7.2.00.1090.02279.21
7.1.330.0190.02979.17
7.1.320.0230.02979.32
7.1.310.0100.02979.07
7.1.300.0160.03679.23
7.1.290.0060.03579.15
7.1.280.0170.02879.26
7.1.270.0170.03379.33
7.1.260.0170.02779.18
7.1.250.0660.03377.95
7.1.240.0130.03079.40
7.1.230.0130.03079.16
7.1.220.0220.02279.17
7.1.210.0140.03779.25
7.1.200.0750.01878.28
7.1.190.0300.02679.14
7.1.180.0140.04679.17
7.1.170.0270.02079.11
7.1.160.0210.03479.08
7.1.150.0170.02878.87
7.1.140.0170.03779.10
7.1.130.0100.04079.24
7.1.120.0260.02079.24
7.1.110.0170.03179.33
7.1.100.0240.03779.26
7.1.90.0350.02079.22
7.1.80.0280.02479.31
7.1.70.1250.03078.48
7.1.60.0220.03379.09
7.1.50.0320.02279.12
7.1.40.0340.02879.13
7.1.30.0310.02479.29
7.1.20.0340.03179.07
7.1.10.0170.04579.43
7.1.00.0170.06281.81
7.0.330.0110.03578.91
7.0.320.0140.02879.07
7.0.310.0190.02579.05
7.0.300.0170.03178.70
7.0.290.0180.03278.67
7.0.280.0210.02879.23
7.0.270.0130.03279.04
7.0.260.0130.03379.07
7.0.250.0120.04679.02
7.0.240.0220.03879.09
7.0.230.0330.02379.08
7.0.220.0300.02079.18
7.0.210.0350.01979.19
7.0.200.2380.02574.81
7.0.190.0070.03779.17
7.0.180.0310.03579.02
7.0.170.0410.02579.29
7.0.160.0240.03878.98
7.0.150.0250.03779.11
7.0.140.0220.03879.00
7.0.130.0320.02479.16
7.0.120.0210.03579.10
7.0.110.0160.04278.93
7.0.100.0140.03579.08
7.0.90.0170.04379.21
7.0.80.0100.05079.06
7.0.70.0170.03178.99
7.0.60.0490.04277.28
7.0.50.0270.04076.22
7.0.40.0120.06917.54
7.0.30.0270.04817.61
7.0.20.0230.06317.56
7.0.10.0290.05417.70
7.0.00.0120.05817.56
5.6.400.0440.03480.58
5.6.390.0370.05080.59
5.6.380.0400.04680.90
5.6.370.0350.03980.66
5.6.360.0260.06880.61
5.6.350.0270.05380.31
5.6.340.0270.06480.60
5.6.330.0400.04380.25
5.6.320.0360.05580.59
5.6.310.0420.05880.47
5.6.300.0480.04980.39
5.6.290.0420.04680.78
5.6.280.0400.08183.16
5.6.270.0470.04080.66
5.6.260.0400.05080.51
5.6.250.0300.07880.55
5.6.240.0300.06680.69
5.6.230.0330.05180.57
5.6.220.0370.05880.48
5.6.210.0210.06682.94
5.6.200.0380.07981.69
5.6.190.0430.07982.84
5.6.180.0340.05682.86
5.6.170.0480.07382.69
5.6.160.0380.06382.85
5.6.150.0400.07881.54
5.6.140.0270.07981.74
5.6.130.0200.06481.70
5.6.120.0330.05183.21
5.6.110.0300.07583.07
5.6.100.0350.05083.13
5.6.90.0300.06283.06
5.6.80.0340.07882.86
5.6.70.0260.05280.61
5.6.60.0420.04680.27
5.6.50.0390.05880.37
5.6.40.0370.05380.45
5.6.30.0490.05680.66
5.6.20.0380.05980.69
5.6.10.0390.06580.39
5.6.00.0200.06480.37
5.5.380.0330.05680.49
5.5.370.0340.05080.46
5.5.360.0400.04980.73
5.5.350.0410.06182.65
5.5.340.0280.06581.59
5.5.330.0250.07982.64
5.5.320.0470.05282.59
5.5.310.0320.05682.62
5.5.300.0220.06081.62
5.5.290.0270.08081.63
5.5.280.0330.08083.06
5.5.270.0220.08182.92
5.5.260.0390.05482.81
5.5.250.0460.06682.89
5.5.240.0390.07182.60
5.5.230.0370.04880.46
5.5.220.0330.04380.49
5.5.210.0270.04880.44
5.5.200.0490.03380.57
5.5.190.0290.05180.22
5.5.180.0320.04580.38
5.5.170.0170.06080.38
5.5.160.0490.05980.55
5.5.150.0340.05580.47
5.5.140.0370.05480.49
5.5.130.0370.04680.30
5.5.120.0370.04780.52
5.5.110.0270.06780.47
5.5.100.0210.06680.34
5.5.90.0370.04080.48
5.5.80.0400.04480.25
5.5.70.0270.04880.11
5.5.60.0290.04880.46
5.5.50.0450.03580.46
5.5.40.0370.05080.29
5.5.30.0280.05280.32
5.5.20.0370.04480.39
5.5.10.0430.04780.15
5.5.00.0380.05080.45

preferences:
66.25 ms | 401 KiB | 5 Q