3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Tree { public $i; public $l; public $r; public function __construct($item, $depth) { $this->i = $item; if($depth) { $this->l = new Tree($item * 2 - 1, --$depth); $this->r = new Tree($item * 2, $depth); } } public function check() { return $this->i + ($this->l->l === null ? $this->l->check() : $this->l->i) - ($this->r->l === null ? $this->r->check() : $this->r->i); } } $minDepth = 10; $n = $argc == 2 ? $argv[1] : 1; $maxDepth = $minDepth + 2 > $n ? $minDepth + 2 : $n; $stretchDepth = $maxDepth + 1; $stretch = new Tree(0, $stretchDepth); printf("stretch tree of depth %d\t check: %d\n", $stretchDepth, $stretch->check()); unset($stretch); $longLivedTree = new Tree(0, $maxDepth); $iterations = 1 << $maxDepth; do { $check = 0; for($i = 1; $i <= $iterations; ++$i) { $check += (new Tree($i, $minDepth))->check() + (new Tree(-$i, $minDepth))->check(); } printf("%d\t trees of depth %d\t check: %d\n", $iterations<<1, $minDepth, $check); $minDepth += 2; $iterations >>= 2; } while($minDepth <= $maxDepth); printf("long lived tree of depth %d\t check: %d\n", $maxDepth, $longLivedTree->check());

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.0101.99418.50
8.3.50.0121.99423.99
8.3.40.0071.99520.60
8.3.30.0171.98620.79
8.3.20.0131.65222.09
8.3.10.0071.63625.77
8.3.00.0071.62321.49
8.2.180.0101.99418.38
8.2.170.0071.99822.96
8.2.160.0101.99020.57
8.2.150.0071.64324.18
8.2.140.0031.60724.66
8.2.130.0071.62026.16
8.2.120.0071.59823.29
8.2.110.0031.99924.24
8.2.100.0231.97219.97
8.2.90.0032.00021.05
8.2.80.0071.99519.50
8.2.70.0032.00419.50
8.2.60.0131.98619.80
8.2.50.0002.00319.38
8.2.40.0032.00020.26
8.2.30.0071.99720.31
8.2.20.0002.00519.55
8.2.10.0002.00119.86
8.2.00.0101.99019.53
8.1.280.0071.99625.92
8.1.270.0101.71126.25
8.1.260.0001.72326.35
8.1.250.0001.65128.09
8.1.240.0071.99624.07
8.1.230.0071.99721.04
8.1.220.0002.00319.66
8.1.210.0032.00019.54
8.1.200.0032.00019.13
8.1.190.0002.00819.13
8.1.180.0032.00019.11
8.1.170.0071.99520.35
8.1.160.0071.99723.96
8.1.150.0002.00420.71
8.1.140.0031.99819.41
8.1.130.0031.99819.40
8.1.120.0002.00419.39
8.1.110.0101.99119.29
8.1.100.0002.00219.45
8.1.90.0002.00319.43
8.1.80.0002.00419.41
8.1.70.0002.00319.31
8.1.60.0101.99119.48
8.1.50.0071.99719.50
8.1.40.0002.00419.46
8.1.30.0071.99419.52
8.1.20.0131.99019.43
8.1.10.0032.00019.39
8.1.00.0131.98519.39
8.0.300.0071.99518.82
8.0.290.0031.99918.25
8.0.280.0001.99920.21
8.0.270.0002.00419.00
8.0.260.0071.99518.52
8.0.250.0002.00218.59
8.0.240.0032.00118.55
8.0.230.0071.99718.64
8.0.220.0101.99118.49
8.0.210.0071.99518.46
8.0.200.0032.00018.52
8.0.190.0002.00318.53
8.0.180.0032.00218.63
8.0.170.0002.00418.66
8.0.160.0032.00018.58
8.0.150.0032.00118.47
8.0.140.0061.99618.39
8.0.130.0071.99715.02
8.0.120.0101.99418.52
8.0.110.0032.00018.54
8.0.100.0031.99818.51
8.0.90.0031.99918.50
8.0.80.0091.99118.44
8.0.70.0031.99918.54
8.0.60.0032.00118.41
8.0.50.0131.98918.52
8.0.30.0151.98918.93
8.0.20.0111.98718.98
8.0.10.0031.99918.50
8.0.00.0111.99118.54
7.4.330.0031.99917.21
7.4.320.0002.00418.21
7.4.300.0032.00018.20
7.4.290.0031.99918.17
7.4.280.0071.99418.19
7.4.270.0032.00018.26
7.4.260.0131.98718.07
7.4.250.0002.00418.20
7.4.240.0071.99618.14
7.4.230.0031.99818.23
7.4.220.0161.99118.18
7.4.210.0061.99318.35
7.4.200.0002.00718.22
7.4.160.0171.98618.30
7.4.150.0261.95218.25
7.4.140.0431.96218.29
7.4.130.0191.97618.34
7.4.120.0131.99018.27
7.4.110.0072.47518.45
7.4.100.0132.46218.17
7.4.90.0172.46218.32
7.4.80.0352.02119.39
7.4.70.0132.37618.27
7.4.60.0332.42618.17
7.4.50.0032.42418.31
7.4.40.0132.44518.18
7.4.30.0222.44918.32
7.4.00.0102.48716.84
7.3.330.0071.99414.96
7.3.320.0032.00115.06
7.3.310.0002.00218.01
7.3.300.0002.00318.05
7.3.290.0291.97017.94
7.3.280.0171.98617.96
7.3.270.0131.98718.21
7.3.260.0161.98618.23
7.3.250.0111.99418.20
7.3.240.0191.97818.00
7.3.230.0192.44218.07
7.3.210.0132.46618.29
7.3.200.0162.44619.39
7.3.190.0162.42818.22
7.3.180.0102.44217.93
7.3.170.0032.46418.18
7.3.160.0162.46318.14
7.2.330.0332.32518.46
7.2.320.0132.45918.50
7.2.310.0072.46718.56
7.2.300.0162.45518.60
7.2.290.0162.45818.59
7.2.110.0332.45219.01
7.2.60.0032.48319.20
7.2.00.0102.36421.71
7.1.200.0102.48718.23
7.1.100.0102.49120.50
7.1.70.0072.49419.34
7.1.60.0102.49119.42
7.1.50.0102.31819.39
7.1.00.0072.49324.53
7.0.200.0132.47719.12
7.0.140.0032.49724.38
7.0.60.0032.49721.93
7.0.50.0102.49019.63
7.0.40.0072.47720.19
7.0.30.0232.47720.28
7.0.20.0072.49320.12
7.0.10.0072.49320.30
7.0.00.0072.49320.23
5.6.210.0072.49324.54
5.6.200.0072.49322.01
5.6.190.0032.49724.33
5.6.180.0502.45024.37
5.6.170.0172.48324.45
5.6.160.0132.48724.41
5.6.150.0072.38022.21
5.6.140.0032.49722.24
5.6.130.0202.48022.15
5.6.120.0032.48024.80
5.6.110.0072.49325.16
5.6.100.0172.48325.05
5.6.90.0102.49024.99
5.6.80.0072.47324.54
5.5.350.0232.47724.46
5.5.340.0072.49322.06
5.5.330.0102.49024.13
5.5.320.0402.46024.14
5.5.310.0272.47324.21
5.5.300.0132.48721.96
5.5.290.0072.47721.95
5.5.280.0072.49324.90
5.5.270.0032.49724.86
5.5.260.0102.49024.91
5.5.250.0032.49724.79
5.5.240.0132.48724.36
5.4.450.0371.73323.21
5.4.440.0402.11023.29
5.4.430.0531.09323.23
5.4.420.0831.43723.41
5.4.410.1302.35323.10
5.4.400.0231.56723.09
5.4.390.0231.50323.02
5.4.380.0202.43322.71
5.4.370.0432.40322.79
5.4.360.0432.42022.78
5.4.350.0332.37022.78
5.4.340.0302.32022.55
5.4.320.0111.98116.52
5.4.310.0101.98616.52
5.4.300.0201.97616.52
5.4.290.0091.98316.51
5.4.280.0111.97916.41
5.4.270.0101.99016.41
5.4.260.0061.99316.41
5.4.250.0091.99016.41
5.4.240.0411.95716.41
5.4.230.0411.96416.41
5.4.220.0121.99016.41
5.4.210.0131.98716.40
5.4.200.0171.98216.41
5.4.190.0111.98416.40
5.4.180.0411.96316.40
5.4.170.0341.95216.41
5.4.160.0751.92916.40
5.4.150.0111.99216.40
5.4.140.0161.98516.09
5.4.130.0111.98816.07
5.4.120.0151.98616.04
5.4.110.0101.99416.03
5.4.100.0121.99116.03
5.4.90.0071.99316.03
5.4.80.0161.98416.03
5.4.70.0091.99116.02
5.4.60.0081.99316.02
5.4.50.0141.98816.02
5.4.40.0071.99216.00
5.4.30.0131.98316.00
5.4.20.0641.83216.01
5.4.10.0131.98516.01
5.4.00.0091.98815.50
5.3.290.0050.03912.80
5.3.280.0060.03612.71
5.3.270.0040.03912.72
5.3.260.0060.03712.72
5.3.250.0060.03612.72
5.3.240.0070.03512.72
5.3.230.0080.03512.71
5.3.220.0040.03812.68
5.3.210.0070.03712.68
5.3.200.0080.03412.68
5.3.190.0060.03712.68
5.3.180.0070.03512.67
5.3.170.0020.04012.67
5.3.160.0080.03312.67
5.3.150.0090.03412.68
5.3.140.0040.03812.66
5.3.130.0080.03612.66
5.3.120.0060.04212.66
5.3.110.0090.04012.66
5.3.100.0070.03612.13
5.3.90.0090.03412.11
5.3.80.0040.04312.11
5.3.70.0060.03612.11
5.3.60.0050.03612.09
5.3.50.0080.03312.04
5.3.40.0060.03512.04
5.3.30.0090.03112.00
5.3.20.0080.03211.77
5.3.10.0050.03411.74
5.3.00.0040.03611.73
5.2.170.0040.0389.23
5.2.160.0040.0319.23
5.2.150.0080.0309.23
5.2.140.0020.0359.23
5.2.130.0020.0319.19
5.2.120.0050.0279.19
5.2.110.0050.0289.20
5.2.100.0020.0309.19
5.2.90.0020.0319.19
5.2.80.0070.0279.19
5.2.70.0030.0369.18
5.2.60.0060.0299.14
5.2.50.0030.0319.11
5.2.40.0050.0289.09
5.2.30.0040.0309.07
5.2.20.0050.0289.05
5.2.10.0010.0318.95
5.2.00.0040.0288.82
5.1.60.0030.0248.11
5.1.50.0060.0228.10
5.1.40.0040.0248.08
5.1.30.0050.0258.43
5.1.20.0050.0258.46
5.1.10.0050.0248.18
5.1.00.0010.0288.18
5.0.50.0050.0186.67
5.0.40.0050.0186.53
5.0.30.0070.0376.34
5.0.20.0040.0196.30
5.0.10.0050.0186.29
5.0.00.0020.0326.27
4.4.90.0030.0154.78
4.4.80.0030.0144.75
4.4.70.0040.0144.76
4.4.60.0000.0184.76
4.4.50.0030.0154.77
4.4.40.0030.0244.70
4.4.30.0040.0144.76
4.4.20.0020.0164.85
4.4.10.0030.0154.85
4.4.00.0030.0244.76
4.3.110.0030.0154.67
4.3.100.0040.0144.66
4.3.90.0020.0164.63
4.3.80.0030.0254.59
4.3.70.0010.0164.63
4.3.60.0050.0114.63
4.3.50.0040.0144.62
4.3.40.0060.0204.54
4.3.30.0010.0163.30
4.3.20.0020.0153.28
4.3.10.0030.0143.23
4.3.00.0030.01715.65

preferences:
43.67 ms | 401 KiB | 5 Q