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 = 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.40
8.3.50.0090.01220.01
8.3.40.0100.01018.71
8.3.30.0110.00419.22
8.3.20.0030.00620.33
8.3.10.0080.00023.69
8.3.00.0030.00519.25
8.2.180.0100.01016.88
8.2.170.0120.00322.96
8.2.160.0110.00720.45
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0060.00326.16
8.2.120.0050.00321.04
8.2.110.0000.01119.25
8.2.100.0110.00317.91
8.2.90.0050.00319.17
8.2.80.0000.01017.97
8.2.70.0080.00417.63
8.2.60.0050.00517.93
8.2.50.0090.00018.07
8.2.40.0060.00319.88
8.2.30.0030.00618.27
8.2.20.0060.00317.87
8.2.10.0040.00418.17
8.2.00.0000.00817.79
8.1.280.0060.01325.92
8.1.270.0060.00322.14
8.1.260.0000.00826.35
8.1.250.0030.00528.09
8.1.240.0030.00622.10
8.1.230.0060.00619.14
8.1.220.0000.00817.79
8.1.210.0040.00418.77
8.1.200.0040.00717.48
8.1.190.0030.00617.38
8.1.180.0000.00818.10
8.1.170.0030.00618.59
8.1.160.0060.00322.06
8.1.150.0040.00418.93
8.1.140.0030.00617.42
8.1.130.0040.00417.87
8.1.120.0080.00017.56
8.1.110.0090.00017.47
8.1.100.0040.00417.50
8.1.90.0030.00517.40
8.1.80.0050.00517.41
8.1.70.0000.00817.39
8.1.60.0070.00317.58
8.1.50.0050.00517.49
8.1.40.0030.00617.56
8.1.30.0060.00317.59
8.1.20.0000.00817.59
8.1.10.0000.00817.53
8.1.00.0030.00617.48
8.0.300.0040.00420.40
8.0.290.0060.00316.75
8.0.280.0020.00518.50
8.0.270.0040.00417.22
8.0.260.0070.00017.30
8.0.250.0000.00716.99
8.0.240.0060.00317.03
8.0.230.0040.00416.82
8.0.220.0000.00716.79
8.0.210.0040.00416.79
8.0.200.0040.00416.90
8.0.190.0040.00516.84
8.0.180.0080.00016.91
8.0.170.0000.00916.77
8.0.160.0000.00916.81
8.0.150.0000.01016.77
8.0.140.0000.00916.75
8.0.130.0040.00413.39
8.0.120.0060.00316.90
8.0.110.0000.00816.81
8.0.100.0050.00316.83
8.0.90.0000.00816.91
8.0.80.0120.01216.91
8.0.70.0030.00516.71
8.0.60.0060.00316.73
8.0.50.0080.00016.76
8.0.30.0170.00617.12
8.0.20.0120.01417.40
8.0.10.0030.00516.98
8.0.00.0080.01216.84
7.4.330.0030.00315.09
7.4.320.0000.00716.64
7.4.300.0000.00916.55
7.4.290.0000.00816.50
7.4.280.0030.00616.54
7.4.270.0000.00816.56
7.4.260.0030.00616.56
7.4.250.0030.00616.52
7.4.240.0040.00416.53
7.4.230.0000.00716.73
7.4.220.0130.01316.68
7.4.210.0070.01516.72
7.4.200.0000.00816.55
7.4.160.0070.01616.41
7.4.150.0170.00617.40
7.4.140.0110.00717.86
7.4.130.0100.01016.56
7.4.120.0120.00916.66
7.4.110.0120.00616.48
7.4.100.0130.00616.56
7.4.90.0130.00916.57
7.4.80.0000.01819.39
7.4.70.0080.01116.68
7.4.60.0090.01616.57
7.4.50.0020.00216.13
7.4.40.0060.01216.74
7.4.30.0140.00316.58
7.4.10.0050.00815.10
7.4.00.0090.01114.98
7.3.330.0000.00613.29
7.3.320.0030.00313.36
7.3.310.0000.00816.38
7.3.300.0030.00516.26
7.3.290.0060.01316.34
7.3.280.0070.01116.31
7.3.270.0110.00717.40
7.3.260.0280.02416.25
7.3.250.0110.01016.39
7.3.240.0060.01516.37
7.3.230.0110.00716.62
7.3.210.0150.00416.57
7.3.200.0090.00919.39
7.3.190.0000.01816.29
7.3.180.0100.00916.37
7.3.170.0060.01116.60
7.3.160.0120.00616.48
7.3.130.0070.01415.04
7.3.120.0090.00915.13
7.3.110.0080.01114.99
7.3.100.0040.01114.81
7.3.90.0000.02115.04
7.3.80.0040.00814.64
7.3.70.0100.00314.82
7.3.60.0060.00614.71
7.3.50.0130.00314.77
7.3.40.0070.01014.70
7.3.30.0040.01114.77
7.3.20.0160.00016.77
7.3.10.0100.00716.49
7.3.00.0070.00716.49
7.2.330.0090.01216.59
7.2.320.0100.01616.85
7.2.310.0000.01816.89
7.2.300.0100.00716.78
7.2.290.0100.01316.81
7.2.260.0120.00914.98
7.2.250.0130.00714.80
7.2.240.0070.01015.18
7.2.230.0070.01515.18
7.2.220.0100.01014.92
7.2.210.0090.00914.79
7.2.200.0000.01014.86
7.2.190.0030.01514.79
7.2.180.0000.01414.86
7.2.170.0070.00715.08
7.2.160.0040.01115.00
7.2.150.0090.00616.92
7.2.140.0090.00917.05
7.2.130.0030.01316.82
7.2.120.0070.01016.89
7.2.110.0040.00816.61
7.2.100.0070.00716.98
7.2.90.0070.01116.74
7.2.80.0070.01116.82
7.2.70.0070.01116.71
7.2.60.0070.01316.94
7.2.50.0000.01216.90
7.2.40.0090.00917.04
7.2.30.0100.01016.82
7.2.20.0040.00716.73
7.2.10.0100.00716.95
7.2.00.0060.00818.00
7.1.330.0060.01316.00
7.1.320.0070.01315.83
7.1.310.0110.00415.97
7.1.300.0060.01015.86
7.1.290.0000.01315.46
7.1.280.0060.00915.70
7.1.270.0060.01015.96
7.1.260.0100.00715.80
7.1.250.0060.01015.72
7.1.240.0070.01015.82
7.1.230.0040.01515.76
7.1.220.0070.01015.68
7.1.210.0080.01115.75
7.1.200.0160.00315.63
7.1.190.0100.00715.79
7.1.180.0130.00015.51
7.1.170.0050.00515.49
7.1.160.0030.01415.81
7.1.150.0000.01715.79
7.1.140.0030.01315.79
7.1.130.0120.00615.86
7.1.120.0000.01715.75
7.1.110.0030.01315.86
7.1.100.0120.00716.77
7.1.90.0070.01015.77
7.1.80.0060.00915.96
7.1.70.0060.00416.40
7.1.60.0070.01617.61
7.1.50.0050.01316.26
7.1.40.0070.00415.63
7.1.30.0000.01615.83
7.1.20.0080.00615.96
7.1.10.0000.01515.75
7.1.00.0050.05119.19
7.0.330.0060.01215.17
7.0.320.0030.01215.29
7.0.310.0030.01515.41
7.0.300.0070.01115.37
7.0.290.0070.01015.26
7.0.280.0030.01315.38
7.0.270.0070.01015.48
7.0.260.0040.01215.08
7.0.250.0120.00315.43
7.0.240.0070.01315.36
7.0.230.0120.00615.29
7.0.220.0130.00315.48
7.0.210.0030.01015.30
7.0.200.0080.00516.00
7.0.190.0060.01315.56
7.0.180.0050.00815.18
7.0.170.0000.01515.39
7.0.160.0130.00315.52
7.0.150.0080.00815.52
7.0.140.0050.04218.78
7.0.130.0090.00315.54
7.0.120.0040.01215.45
7.0.110.0000.01715.53
7.0.100.0080.04717.73
7.0.90.0040.04617.53
7.0.80.0120.04317.74
7.0.70.0070.04617.72
7.0.60.0040.04417.64
7.0.50.0070.04317.93
7.0.40.0080.03316.81
7.0.30.0120.03716.68
7.0.20.0110.04316.88
7.0.10.0100.04116.76
7.0.00.0050.04716.80
5.6.400.0070.01414.72
5.6.390.0030.01614.74
5.6.380.0120.00614.28
5.6.370.0060.01214.57
5.6.360.0030.01614.27
5.6.350.0060.01614.68
5.6.340.0030.01614.47
5.6.330.0030.01714.36
5.6.320.0040.01414.78
5.6.310.0030.01714.54
5.6.300.0060.01014.54
5.6.290.0060.01314.58
5.6.280.0090.04317.73
5.6.270.0110.01114.77
5.6.260.0070.01014.68
5.6.250.0080.03017.71
5.6.240.0050.04917.57
5.6.230.0050.05317.66
5.6.220.0080.04717.55
5.6.210.0030.04917.59
5.6.200.0040.03317.70
5.6.190.0050.03717.78
5.6.180.0020.05617.72
5.6.170.0050.04817.93
5.6.160.0060.04617.72
5.6.150.0040.04617.85
5.6.140.0030.03117.64
5.6.130.0070.05017.73
5.6.120.0140.03817.70
5.6.110.0040.05417.68
5.6.100.0050.05017.86
5.6.90.0050.05217.69
5.6.80.0020.03617.35
5.6.70.0080.04317.49
5.6.60.0080.04717.51
5.6.50.0080.02817.37
5.6.40.0150.02617.46
5.6.30.0070.02417.49
5.6.20.0070.02917.43
5.6.10.0030.03017.31
5.6.00.0050.03217.31
5.5.380.0050.04517.34
5.5.370.0100.04017.57
5.5.360.0020.04417.44
5.5.350.0080.04517.48
5.5.340.0030.05017.71
5.5.330.0050.05017.82
5.5.320.0150.04317.64
5.5.310.0130.03017.83
5.5.300.0070.04317.56
5.5.290.0020.05717.60
5.5.280.0080.04817.63
5.5.270.0070.05017.76
5.5.260.0110.05017.84
5.5.250.0070.04117.54
5.5.240.0100.04517.35
5.5.230.0080.04717.43
5.5.220.0050.02717.36
5.5.210.0060.02817.33
5.5.200.0030.04517.33
5.5.190.0030.03317.43
5.5.180.0030.03417.16
5.5.170.0060.01314.45
5.5.160.0050.03217.42
5.5.150.0050.02817.40
5.5.140.0080.03117.37
5.5.130.0060.03617.39
5.5.120.0030.03717.40
5.5.110.0130.03517.15
5.5.100.0080.04117.46
5.5.90.0020.05217.32
5.5.80.0020.05117.16
5.5.70.0050.04517.36
5.5.60.0050.02517.07
5.5.50.0030.02517.36
5.5.40.0050.02717.17
5.5.30.0070.03717.13
5.5.20.0060.02617.18
5.5.10.0030.02917.29
5.5.00.0030.02817.11
5.4.450.0100.04215.40
5.4.440.0090.02815.34
5.4.430.0050.05015.34
5.4.420.0020.05015.42
5.4.410.0080.03215.38
5.4.400.0100.03815.02
5.4.390.0030.03815.14
5.4.380.0050.03815.20
5.4.370.0080.02814.96
5.4.360.0060.03615.05
5.4.350.0090.03415.07
5.4.340.0070.02515.16
5.4.330.0030.01511.48
5.4.320.0080.03115.04
5.4.310.0070.03715.18
5.4.300.0120.01715.16
5.4.290.0020.04314.93
5.4.280.0100.04215.17
5.4.270.0030.04015.21
5.4.260.0030.04415.15
5.4.250.0050.03915.13
5.4.240.0030.02714.98
5.4.230.0100.03215.13
5.4.220.0090.02215.02
5.4.210.0020.03515.26
5.4.200.0050.02914.98
5.4.190.0080.02515.11
5.4.180.0050.02614.92
5.4.170.0070.02115.16
5.4.160.0030.02415.12
5.4.150.0030.02615.01
5.4.140.0030.02513.85
5.4.130.0030.04513.97
5.4.120.0000.03013.85
5.4.110.0020.03013.70
5.4.100.0050.03013.79
5.4.90.0050.04713.85
5.4.80.0030.03513.87
5.4.70.0030.02514.00
5.4.60.0030.02513.97
5.4.50.0040.02213.87
5.4.40.0070.02313.82
5.4.30.0020.02513.87
5.4.20.0020.02813.88
5.4.10.0020.02613.76
5.4.00.0100.03713.61
5.3.290.0030.04314.74
5.3.280.0030.04714.66
5.3.270.0030.04714.65
5.3.260.0030.04314.57
5.3.250.0070.03314.60
5.3.240.0170.05014.74
5.3.230.0070.04014.63
5.3.220.0000.04314.57
5.3.210.0100.02714.50
5.3.200.0000.04014.64
5.3.190.0030.03714.51
5.3.180.0030.04014.61
5.3.170.0000.04014.58
5.3.160.0130.02714.51
5.3.150.0030.04314.64
5.3.140.0030.06314.59
5.3.130.0100.03014.68
5.3.120.0030.03714.59
5.3.110.0030.08014.63
5.3.100.0030.03714.18
5.3.90.0000.04714.06
5.3.80.0070.03013.94
5.3.70.0000.05014.06
5.3.60.0130.06014.13
5.3.50.0070.07014.05
5.3.40.0130.07014.01
5.3.30.0030.05013.85
5.3.20.0070.06313.81
5.3.10.0100.06313.67
5.3.00.0030.07013.58
5.2.170.0070.06011.14
5.2.160.0070.05311.21
5.2.150.0070.06711.22
5.2.140.0030.06711.26
5.2.130.0030.06711.15
5.2.120.0030.06011.12
5.2.110.0030.05711.22
5.2.100.0100.05711.06
5.2.90.0100.02711.06
5.2.80.0070.06011.06
5.2.70.0030.03011.13
5.2.60.0030.03311.09
5.2.50.0070.06311.14
5.2.40.0100.04711.11
5.2.30.0100.03711.06
5.2.20.0100.03311.09
5.2.10.0000.06311.06
5.2.00.0030.06311.06
5.1.60.0000.05711.06
5.1.50.0030.05711.06
5.1.40.0000.05311.06
5.1.30.0000.05711.06
5.1.20.0030.05711.06
5.1.10.0030.05311.06
5.1.00.0030.05711.06
5.0.50.0130.03311.06
5.0.40.0070.04011.06
5.0.30.0030.06011.06
5.0.20.0030.04711.06
5.0.10.0070.04311.06
5.0.00.0030.06311.06
4.4.90.0030.02711.06
4.4.80.0000.03711.06
4.4.70.0030.03711.06
4.4.60.0030.03711.06
4.4.50.0070.03011.06
4.4.40.0000.04011.06
4.4.30.0070.03311.06
4.4.20.0070.03011.06
4.4.10.0000.03011.06
4.4.00.0070.04311.06
4.3.110.0030.03311.06
4.3.100.0000.03311.06
4.3.90.0070.03011.06
4.3.80.0000.05311.06
4.3.70.0000.02711.06
4.3.60.0000.03011.06
4.3.50.0070.02311.06
4.3.40.0000.05311.06
4.3.30.0000.02011.06
4.3.20.0070.03011.06
4.3.10.0000.03711.06
4.3.00.0000.03311.06

preferences:
53.18 ms | 400 KiB | 5 Q