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 = 20; $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.70.0770.11777.42
8.3.60.0860.11677.43
8.3.50.0550.14279.04
8.3.40.0260.06245.54
8.3.30.0300.04646.23
8.3.20.0100.03047.39
8.3.10.0190.01949.11
8.3.00.0130.02044.82
8.2.180.0700.11377.38
8.2.170.0290.04845.80
8.2.160.0270.04547.22
8.2.150.0250.01646.02
8.2.140.0250.01846.27
8.2.130.0090.01848.85
8.2.120.0030.02746.50
8.2.110.0200.04147.39
8.2.100.0420.04344.78
8.2.90.0240.03144.93
8.2.80.0130.03944.91
8.2.70.0170.03844.80
8.2.60.0100.04544.68
8.2.50.0140.03646.20
8.2.40.0110.05647.30
8.2.30.0070.04644.86
8.2.20.0130.04644.58
8.2.10.0130.03945.14
8.2.00.0170.03744.58
8.1.280.0570.18678.81
8.1.270.0170.03849.19
8.1.260.0110.03547.38
8.1.250.0230.02349.05
8.1.240.0130.04349.37
8.1.230.0380.05146.02
8.1.220.0160.04244.66
8.1.210.0070.05344.35
8.1.200.0140.05644.23
8.1.190.0100.05344.35
8.1.180.0130.04444.23
8.1.170.0210.03545.60
8.1.160.0100.04648.94
8.1.150.0280.03145.88
8.1.140.0070.05144.39
8.1.130.0110.04344.82
8.1.120.0130.04044.40
8.1.110.0100.04644.46
8.1.100.0200.04044.31
8.1.90.0070.05344.40
8.1.80.0200.05344.40
8.1.70.0160.04244.35
8.1.60.0140.05844.56
8.1.50.0170.04844.36
8.1.40.0160.04544.46
8.1.30.0230.04244.53
8.1.20.0100.05244.40
8.1.10.0230.16178.49
8.1.00.0260.16578.34
8.0.300.0490.12981.71
8.0.290.0230.14977.35
8.0.280.0230.14979.23
8.0.270.0310.14677.90
8.0.260.0270.14977.98
8.0.250.0370.13077.59
8.0.240.0300.15077.69
8.0.230.0200.15177.57
8.0.220.0300.13977.51
8.0.210.0360.13577.47
8.0.200.0330.13977.63
8.0.190.0270.18577.66
8.0.180.0230.18177.56
8.0.170.0470.15577.59
8.0.160.0340.16277.43
8.0.150.0270.16077.53
8.0.140.0230.17977.28
8.0.130.0440.268119.86
8.0.120.0300.17077.49
8.0.110.0270.15977.49
8.0.100.0130.16877.50
8.0.90.0170.16577.32
8.0.80.0600.30277.52
8.0.70.0330.15177.52
8.0.60.0230.16577.45
8.0.50.0360.15677.55
8.0.30.0690.32377.69
8.0.20.0710.29777.60
8.0.10.0270.17077.61
8.0.00.0690.30777.49
7.4.330.0170.15274.14
7.4.320.0270.15877.17
7.4.300.0230.17277.08
7.4.290.0330.16877.28
7.4.280.0400.16877.16
7.4.270.0300.16777.23
7.4.260.0300.17777.24
7.4.250.0400.18877.23
7.4.240.0300.17377.29
7.4.230.0270.16777.32
7.4.220.1890.32777.21
7.4.210.0630.33077.13
7.4.200.0270.17477.09
7.4.160.0550.25177.30
7.4.150.1020.27177.23
7.4.140.0850.28777.27
7.4.130.0700.25977.37
7.4.120.0640.32777.28
7.4.110.0590.27577.25
7.4.100.0890.36077.07
7.4.90.0760.29277.19
7.4.80.0770.27077.26
7.4.70.0810.33977.25
7.4.60.0700.26777.22
7.4.50.0200.14577.48
7.4.40.0660.31877.31
7.4.30.0650.26777.15
7.4.00.0300.20375.80
7.3.330.0640.268119.79
7.3.320.0670.260120.04
7.3.310.0300.20176.86
7.3.300.0230.19076.83
7.3.290.0630.25376.89
7.3.280.0620.32477.00
7.3.270.1120.30777.06
7.3.260.0750.31977.23
7.3.250.0840.26277.25
7.3.240.0910.31077.32
7.3.230.0660.28877.20
7.3.210.0800.28877.32
7.3.200.0690.32477.24
7.3.190.0850.30876.89
7.3.180.0630.32076.95
7.3.170.0780.29677.21
7.3.160.0560.29276.94
7.3.10.1520.17677.24
7.3.00.1060.16776.93
7.2.330.0740.23976.76
7.2.320.0780.21976.84
7.2.310.0830.26976.61
7.2.300.0720.24776.71
7.2.290.0930.30676.80
7.2.130.0760.16677.07
7.2.120.0880.20277.11
7.2.110.0940.18777.05
7.2.100.0850.19077.01
7.2.90.1150.17177.17
7.2.80.1120.19076.86
7.2.70.1160.18576.78
7.2.60.1260.17277.14
7.2.50.1690.17877.20
7.2.40.1300.17676.98
7.2.30.1200.19677.21
7.2.20.1270.18876.77
7.2.10.1520.16177.11
7.2.00.3920.17678.25
7.1.250.0870.23175.97
7.1.200.1040.17776.11
7.1.100.4390.19578.20
7.1.70.1370.14777.34
7.1.60.0170.16577.72
7.1.50.0540.17577.49
7.1.00.0030.26082.48
7.0.201.9580.15976.95
7.0.140.0070.24082.28
7.0.60.0200.22380.07
7.0.50.0270.19777.95
7.0.40.0100.21728.02
7.0.30.0600.23328.13
7.0.20.0330.19028.09
7.0.10.0130.21327.96
7.0.00.0300.24728.12
5.6.280.0300.24084.01
5.6.210.0200.20383.40
5.6.200.0330.22381.03
5.6.190.0230.24783.29
5.6.180.0970.23083.07
5.6.170.0530.18083.19
5.6.160.0270.23083.20
5.6.150.0330.22081.01
5.6.140.0130.19780.97
5.6.130.0300.23381.06
5.6.120.0300.18083.85
5.6.110.0270.16783.80
5.6.100.0230.24083.85
5.6.90.0130.23383.76
5.6.80.0230.23083.28
5.5.350.0500.22783.41
5.5.340.0330.24080.82
5.5.330.0400.21783.17
5.5.320.0700.22783.12
5.5.310.0230.18783.02
5.5.300.0170.18780.92
5.5.290.0400.18380.90
5.5.280.0270.21083.86
5.5.270.0370.23383.73
5.5.260.0200.27083.84
5.5.250.0230.24383.43
5.5.240.0370.22783.04
5.4.450.1070.23382.19
5.4.440.1070.21382.23
5.4.430.0800.24082.43
5.4.420.0700.21782.21
5.4.410.0770.23782.10
5.4.400.0600.23781.89
5.4.390.0600.23782.03
5.4.380.0600.26081.57
5.4.370.0730.31781.37
5.4.360.1170.27781.42
5.4.350.1170.30081.56
5.4.340.1300.38381.35
5.4.320.0320.18875.37
5.4.310.0310.19975.37
5.4.300.0300.19375.37
5.4.290.0360.18975.37
5.4.280.0270.20275.26
5.4.270.0230.20875.27
5.4.260.0270.19975.26
5.4.250.0260.19475.27
5.4.240.0240.20075.27
5.4.230.0260.20075.25
5.4.220.0310.22075.26
5.4.210.0320.20475.26
5.4.200.0270.23075.26
5.4.190.0380.18875.26
5.4.180.0300.19075.25
5.4.170.0340.24075.26
5.4.160.0260.19275.27
5.4.150.0210.20775.26
5.4.140.0270.20374.94
5.4.130.0140.21374.93
5.4.120.0290.23874.88
5.4.110.0360.22574.88
5.4.100.0290.20174.88
5.4.90.0280.19974.89
5.4.80.0270.19374.88
5.4.70.0280.21174.88
5.4.60.0370.31074.88
5.4.50.0390.28174.88
5.4.40.0230.20474.86
5.4.30.0240.21374.86
5.4.20.0340.19874.87
5.4.10.0190.21574.86
5.4.00.0350.21274.35
5.3.290.0060.04112.80
5.3.280.0040.03912.71
5.3.270.0050.04112.72
5.3.260.0070.04012.72
5.3.250.0040.03912.71
5.3.240.0100.03412.72
5.3.230.0070.03612.71
5.3.220.0080.03612.68
5.3.210.0070.03912.68
5.3.200.0050.03712.68
5.3.190.0040.04012.68
5.3.180.0040.04112.68
5.3.170.0050.03812.67
5.3.160.0060.03712.68
5.3.150.0050.03812.67
5.3.140.0050.03812.66
5.3.130.0090.03612.66
5.3.120.0050.03912.66
5.3.110.0070.03712.66
5.3.100.0070.03612.13
5.3.90.0060.03912.11
5.3.80.0050.04112.11
5.3.70.0070.03612.11
5.3.60.0080.03512.09
5.3.50.0080.03412.04
5.3.40.0030.04012.04
5.3.30.0060.03412.00
5.3.20.0040.03711.77
5.3.10.0040.03711.74
5.3.00.0030.04011.73
5.2.170.0030.0329.23
5.2.160.0040.0299.23
5.2.150.0050.0309.23
5.2.140.0040.0319.23
5.2.130.0030.0309.19
5.2.120.0060.0279.19
5.2.110.0060.0359.20
5.2.100.0050.0289.20
5.2.90.0030.0309.19
5.2.80.0030.0329.19
5.2.70.0080.0279.19
5.2.60.0040.0319.14
5.2.50.0050.0299.11
5.2.40.0040.0299.09
5.2.30.0030.0319.06
5.2.20.0070.0269.05
5.2.10.0070.0268.95
5.2.00.0050.0408.83
5.1.60.0090.0308.11
5.1.50.0060.0348.10
5.1.40.0040.0368.08
5.1.30.0060.0368.43
5.1.20.0070.0368.45
5.1.10.0020.0378.18
5.1.00.0050.0248.18
5.0.50.0030.0216.66
5.0.40.0030.0196.53
5.0.30.0020.0326.34
5.0.20.0030.0196.30
5.0.10.0020.0216.29
5.0.00.0020.0316.28
4.4.90.0010.0174.78
4.4.80.0040.0134.75
4.4.70.0020.0164.75
4.4.60.0030.0154.75
4.4.50.0030.0154.77
4.4.40.0030.0254.71
4.4.30.0030.0164.76
4.4.20.0020.0174.85
4.4.10.0040.0164.85
4.4.00.0030.0244.76
4.3.110.0030.0164.66
4.3.100.0050.0124.66
4.3.90.0050.0114.64
4.3.80.0010.0264.58
4.3.70.0000.0184.63
4.3.60.0020.0154.63
4.3.50.0010.0174.63
4.3.40.0030.0234.54
4.3.30.0040.0133.30
4.3.20.0020.0163.28
4.3.10.0020.0153.23
4.3.00.0100.02015.65

preferences:
42.01 ms | 401 KiB | 5 Q