3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* The Computer Language Benchmarks Game http://benchmarksgame.alioth.debian.org/ contributed by Peter Baltruschat modified by Levi Cameron modified by Craig Russell */ 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 = 4; $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.0090.00618.29
8.3.50.0100.01022.76
8.3.40.0060.01018.77
8.3.30.0060.01019.07
8.3.20.0000.00820.34
8.3.10.0080.00023.66
8.3.00.0060.00319.25
8.2.180.0130.00316.75
8.2.170.0110.00722.96
8.2.160.0040.01120.52
8.2.150.0030.00524.18
8.2.140.0050.00324.66
8.2.130.0000.00826.16
8.2.120.0000.00820.98
8.2.110.0030.00621.98
8.2.100.0080.00418.07
8.2.90.0030.00819.21
8.2.80.0030.00617.97
8.2.70.0030.00717.75
8.2.60.0060.00317.92
8.2.50.0030.00618.07
8.2.40.0060.00319.88
8.2.30.0000.00818.24
8.2.20.0040.00417.88
8.2.10.0040.00418.21
8.2.00.0000.00917.92
8.1.280.0160.00425.92
8.1.270.0030.00622.11
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0040.00723.92
8.1.230.0120.00019.18
8.1.220.0030.00617.74
8.1.210.0080.00018.77
8.1.200.0080.00317.23
8.1.190.0000.00817.35
8.1.180.0040.00418.10
8.1.170.0000.00818.50
8.1.160.0040.00422.12
8.1.150.0040.00418.93
8.1.140.0030.00517.47
8.1.130.0000.00717.72
8.1.120.0030.00517.56
8.1.110.0060.00317.41
8.1.100.0050.00317.52
8.1.90.0030.00517.41
8.1.80.0080.00317.46
8.1.70.0070.00017.45
8.1.60.0070.00317.60
8.1.50.0060.00317.61
8.1.40.0040.00417.59
8.1.30.0060.00317.68
8.1.20.0040.00417.63
8.1.10.0080.00017.63
8.1.00.0030.00617.59
8.0.300.0040.00418.77
8.0.290.0040.00416.88
8.0.280.0000.00818.41
8.0.270.0040.00417.31
8.0.260.0000.00717.30
8.0.250.0040.00417.01
8.0.240.0000.00716.97
8.0.230.0000.00716.88
8.0.220.0020.00516.89
8.0.210.0040.00416.89
8.0.200.0040.00417.01
8.0.190.0030.00617.01
8.0.180.0080.00016.95
8.0.170.0000.00916.86
8.0.160.0060.00316.88
8.0.150.0080.00016.72
8.0.140.0050.00516.68
8.0.130.0030.00313.36
8.0.120.0040.00416.85
8.0.110.0040.00416.88
8.0.100.0000.00816.67
8.0.90.0060.00316.88
8.0.80.0060.00916.89
8.0.70.0060.00316.84
8.0.60.0040.00416.82
8.0.50.0000.00816.83
8.0.30.0120.00817.00
8.0.20.0090.01617.40
8.0.10.0030.00616.94
8.0.00.0110.00816.85
7.4.330.0030.00315.00
7.4.320.0000.00816.58
7.4.300.0030.00516.54
7.4.290.0050.00316.58
7.4.280.0030.00616.69
7.4.270.0040.00416.48
7.4.260.0060.00316.55
7.4.250.0000.00916.53
7.4.240.0040.00616.57
7.4.230.0040.00416.59
7.4.220.0060.01316.66
7.4.210.0110.00716.50
7.4.200.0080.00016.44
7.4.160.0120.00816.46
7.4.150.0130.01017.40
7.4.140.0080.01017.86
7.4.130.0100.00816.56
7.4.120.0100.01316.64
7.4.110.0080.01116.77
7.4.100.0120.00616.57
7.4.90.0180.00016.68
7.4.80.0230.00319.39
7.4.70.0090.01116.50
7.4.60.0120.00616.64
7.4.50.0050.00216.48
7.4.40.0140.00616.64
7.4.30.0150.00816.59
7.4.00.0000.01414.93
7.3.330.0000.00613.32
7.3.320.0030.00313.16
7.3.310.0050.00316.39
7.3.300.0060.00316.35
7.3.290.0090.01216.42
7.3.280.0070.00916.35
7.3.270.0160.01017.40
7.3.260.0120.00916.61
7.3.250.0050.01316.49
7.3.240.0060.01916.54
7.3.230.0030.01416.58
7.3.210.0070.01816.57
7.3.200.0120.01219.39
7.3.190.0100.01316.46
7.3.180.0070.01316.38
7.3.170.0060.01216.36
7.3.160.0140.00416.55
7.3.10.0130.01016.39
7.3.00.0100.01416.57
7.2.330.0080.01116.88
7.2.320.0040.01516.74
7.2.310.0070.01116.64
7.2.300.0040.01616.80
7.2.290.0100.01016.48
7.2.130.0120.01216.35
7.2.120.0250.01116.84
7.2.110.0130.02016.67
7.2.100.0130.01416.65
7.2.90.0280.00916.76
7.2.80.0220.00616.44
7.2.70.0170.01416.11
7.2.60.0190.01516.58
7.2.50.0200.00716.36
7.2.40.0180.01116.74
7.2.30.0140.02016.46
7.2.20.0070.01716.21
7.2.10.0120.02016.24
7.2.00.0110.01018.23
7.1.250.0130.01615.57
7.1.100.0200.01118.13
7.1.70.0030.00717.23
7.1.60.0100.01719.40
7.1.50.0100.01317.04
7.1.00.0130.07022.36
7.0.200.0030.00616.82
7.0.140.0070.07322.08
7.0.100.0330.08319.93
7.0.90.0130.07019.92
7.0.80.0330.07720.05
7.0.70.0070.05019.95
7.0.60.0100.07020.09
7.0.50.0200.06720.28
7.0.40.0130.05020.18
7.0.30.0070.09320.04
7.0.20.0070.08320.05
7.0.10.0030.08020.08
7.0.00.0070.08720.03
5.6.250.0070.08320.76
5.6.240.0100.09020.70
5.6.230.0030.08320.66
5.6.220.0100.08020.73
5.6.210.0170.07320.55
5.6.200.0070.08721.03
5.6.190.0070.08721.14
5.6.180.0100.08321.01
5.6.170.0070.09021.01
5.6.160.0100.07021.20
5.6.150.0100.08021.15
5.6.140.0100.07021.07
5.6.130.0130.08021.11
5.6.120.0100.08321.23
5.6.110.0070.08020.99
5.6.100.0030.08021.11
5.6.90.0030.06021.16
5.6.80.0070.07320.47
5.6.70.0100.07020.46
5.6.60.0130.07720.57
5.6.50.0270.03320.55
5.6.40.0070.04720.38
5.6.30.0030.05320.33
5.6.20.0070.07720.55
5.6.10.0030.06720.42
5.6.00.0170.07020.43
5.5.380.0070.08720.57
5.5.370.0000.06320.42
5.5.360.0130.07720.43
5.5.350.0070.09020.50
5.5.340.0100.08020.98
5.5.330.0070.08320.95
5.5.320.0100.07320.89
5.5.310.0100.05320.86
5.5.300.0130.07720.93
5.5.290.0100.08720.93
5.5.280.0030.08020.93
5.5.270.0070.09320.97
5.5.260.0170.04720.79
5.5.250.0000.09020.70
5.5.240.0030.04720.28
5.5.230.0030.07320.26
5.5.220.0130.07320.27
5.5.210.0070.05020.07
5.5.200.0100.08020.20
5.5.190.0100.05720.25
5.5.180.0070.08320.29
5.5.160.0100.08320.30
5.5.150.0000.08720.30
5.5.140.0070.08320.18
5.5.130.0030.09020.05
5.5.120.0100.08020.29
5.5.110.0030.09020.32
5.5.100.0130.07720.11
5.5.90.0070.07320.16
5.5.80.0070.08320.06
5.5.70.0130.08020.13
5.5.60.0100.08320.16
5.5.50.0130.07720.12
5.5.40.0070.04020.10
5.5.30.0100.04720.11
5.5.20.0100.05320.17
5.5.10.0030.07020.16
5.5.00.0030.09020.03
5.4.450.0030.09319.38
5.4.440.0100.07019.46
5.4.430.0100.05719.42
5.4.420.0030.07719.27
5.4.410.0130.07719.23
5.4.400.0070.06318.86
5.4.390.0070.05019.16
5.4.380.0030.08718.89
5.4.370.0070.07319.14
5.4.360.0100.07719.10
5.4.350.0000.07719.19
5.4.340.0100.08318.98
5.4.320.0170.07018.88
5.4.310.0100.07319.13
5.4.300.0130.07319.09
5.4.290.0070.08018.85
5.4.280.0130.07318.89
5.4.270.0030.05018.88
5.4.260.0100.06318.85
5.4.250.0100.07319.06
5.4.240.0100.08018.88
5.4.230.0100.06719.04
5.4.220.0100.07319.04
5.4.210.0070.08319.04
5.4.200.0100.07019.23
5.4.190.0070.07318.87
5.4.180.0130.07719.04
5.4.170.0100.04318.94
5.4.160.0070.09019.01
5.4.150.0070.05319.11
5.4.140.0000.08716.49
5.4.130.0070.07716.38
5.4.120.0070.07716.50
5.4.110.0100.07316.49
5.4.100.0030.08016.39
5.4.90.0030.07716.59
5.4.80.0130.06716.53
5.4.70.0100.07316.52
5.4.60.0030.04716.52
5.4.50.0100.07316.37
5.4.40.0070.07716.45
5.4.30.0100.05316.47
5.4.20.0030.04316.46
5.4.10.0100.07016.49
5.4.00.0000.05715.85
5.3.290.0100.07014.80
5.3.280.0070.07714.64
5.3.270.0100.07014.55
5.3.260.0000.08014.75
5.3.250.0030.07314.70
5.3.240.0030.07314.60
5.3.230.0070.07314.75
5.3.220.0070.07714.59
5.3.210.0100.07014.64
5.3.200.0130.07314.53
5.3.190.0170.06714.64
5.3.180.0100.05014.67
5.3.170.0070.06314.56
5.3.160.0030.08314.57
5.3.150.0070.07014.55
5.3.140.0100.07314.55
5.3.130.0070.05014.57
5.3.120.0100.07314.68
5.3.110.0030.04014.53
5.3.100.0170.07014.18
5.3.90.0070.07013.97
5.3.80.0070.06714.09
5.3.70.0030.07313.92
5.3.60.0030.04314.08
5.3.50.0100.06013.87
5.3.40.0030.07313.87
5.3.30.0200.03713.95
5.3.20.0130.06013.77
5.3.10.0070.07713.58
5.3.00.0100.06013.57
5.2.170.0100.05312.17
5.2.160.0000.06312.17
5.2.150.0070.06012.17
5.2.140.0000.07012.17
5.2.130.0100.05712.17
5.2.120.0030.03712.17
5.2.110.0030.05712.17
5.2.100.0070.06012.17
5.2.90.0030.06312.17
5.2.80.0070.05312.17
5.2.70.0030.06012.17
5.2.60.0170.05012.17
5.2.50.0000.06312.17
5.2.40.0000.04012.17
5.2.30.0070.06012.17
5.2.20.0100.06012.17
5.2.10.0070.06012.17
5.2.00.0030.06012.17
5.1.60.0070.05012.17
5.1.50.0100.04712.17
5.1.40.0000.04712.17
5.1.30.0030.06012.17
5.1.20.0070.02712.17
5.1.10.0030.02312.17
5.1.00.0030.05312.17
5.0.50.0030.03712.17
5.0.40.0030.01712.17
5.0.30.0030.03012.17
5.0.20.0000.02312.17
5.0.10.0030.01712.17
5.0.00.0000.03012.17
4.4.90.0070.02312.17
4.4.80.0070.01312.17
4.4.70.0000.03712.17
4.4.60.0070.02712.17
4.4.50.0000.03312.17
4.4.40.0000.05712.17
4.4.30.0070.03012.17
4.4.20.0070.01312.17
4.4.10.0000.02012.17
4.4.00.0000.02712.17
4.3.110.0000.01712.17
4.3.100.0030.01312.17
4.3.90.0070.01012.17
4.3.80.0000.02312.17
4.3.70.0030.01312.17
4.3.60.0030.01312.17
4.3.50.0030.01312.17
4.3.40.0000.02712.17
4.3.30.0000.01712.17
4.3.20.0000.01712.17
4.3.10.0030.01312.17
4.3.00.0000.01712.17

preferences:
46.54 ms | 401 KiB | 5 Q