3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MenuLinkTreeElement { public $link; public $subtree; public $depth; public $hasChildren; public $inActiveTrail; public $access; public $options; public function __construct($link, $has_children, $depth, $in_active_trail, array $subtree) { $this->link = $link; $this->hasChildren = $has_children; $this->depth = $depth; $this->subtree = $subtree; $this->inActiveTrail = $in_active_trail; $this->access = NULL; $this->options = array(); } public function count() { $sum = function ($carry, MenuLinkTreeElement $element) { return $carry + $element->count(); }; return 1 + array_reduce($this->subtree, $sum); } } // Arrays. $memory_before = memory_get_usage(); $array_start = microtime(TRUE); $storage = array(); for ($i = 0; $i < 1000; $i++) { $storage[] = array( 'link' => new StdClass(), 'has_children' => TRUE, 'depth' => 3, 'in_active_trail' => FALSE, 'below' => array(), 'access' => NULL, 'options' => array(), ); } $array_time = microtime(TRUE) - $array_start; $array_memory = memory_get_usage() - $memory_before; unset($storage); // Objects. $memory_before = memory_get_usage(); $object_start = microtime(TRUE); $storage = array(); for ($i = 0; $i < 1000; $i++) { $storage[] = new MenuLinkTreeElement(new StdClass(), TRUE, 3, FALSE, array()); } $object_time = microtime(TRUE) - $object_start; $object_memory = memory_get_usage() - $memory_before; unset($storage); echo 'arrays: ' . number_format($array_time, 3) . ' s, ' . ($array_memory/1024) . " KB\n"; echo 'objects: ' . number_format($object_time, 3) . ' s, ' . ($object_memory/1024) . " KB\n";

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)
7.2.00.0030.01019.40
7.1.70.0000.01117.32
7.1.60.0110.01119.46
7.1.50.0140.00735.04
7.1.00.0030.07722.57
7.0.200.0000.00916.91
7.0.140.0070.07322.00
7.0.100.0070.05320.76
7.0.90.0030.09020.76
7.0.80.0030.05720.70
7.0.70.0100.04020.72
7.0.60.0100.04320.81
7.0.50.0030.04321.17
7.0.40.0030.05020.21
7.0.30.0030.05020.23
7.0.20.0030.03720.09
7.0.10.0070.04020.13
7.0.00.0030.04320.18
5.6.280.0100.06722.38
5.6.250.0170.07322.02
5.6.240.0100.08321.81
5.6.230.0100.07322.02
5.6.220.0130.07721.93
5.6.210.0070.08721.79
5.6.200.0070.08322.23
5.6.190.0200.03322.34
5.6.180.0170.03722.26
5.6.170.0000.05022.30
5.6.160.0000.04022.25
5.6.150.0070.04022.35
5.6.140.0000.04722.30
5.6.130.0070.04322.29
5.6.120.0030.08322.38
5.6.110.0070.05022.23
5.6.100.0100.03022.17
5.6.90.0000.05022.42
5.6.80.0030.03721.70
5.6.70.0000.05021.64
5.6.60.0030.04321.75
5.6.50.0170.03021.71
5.6.40.0070.06021.74
5.6.30.0100.03021.71
5.6.20.0100.03021.79
5.6.10.0030.04321.71
5.6.00.0170.02721.78
5.5.380.0030.08321.70
5.5.370.0030.08721.67
5.5.360.0100.08021.80
5.5.350.0000.05021.73
5.5.340.0070.06322.04
5.5.330.0200.02722.18
5.5.320.0070.03722.17
5.5.310.0130.03322.10
5.5.300.0070.04722.16
5.5.290.0000.05022.05
5.5.280.0000.04022.05
5.5.270.0000.04022.03
5.5.260.0000.04022.07
5.5.250.0070.03321.97
5.5.240.0030.05321.46
5.5.230.0000.04321.51
5.5.220.0030.04021.41
5.5.210.0030.03321.49
5.5.200.0130.03321.57
5.5.190.0030.04321.46
5.5.180.0030.03321.57
5.5.160.0070.03321.39
5.5.150.0070.03021.53
5.5.140.0030.03321.42
5.5.130.0030.05021.39
5.5.120.0070.03721.46
5.5.110.0000.06321.28
5.5.100.0070.04021.29
5.5.90.0070.07321.38
5.5.80.0000.04721.45
5.5.70.0070.07721.27
5.5.60.0130.07721.30
5.5.50.0100.06321.46
5.5.40.0000.09021.34
5.5.30.0070.04721.36
5.5.20.0070.04021.36
5.5.10.0000.04321.35
5.5.00.0100.08021.34
5.4.450.0100.04020.41
5.4.440.0000.04020.59
5.4.430.0030.03720.58
5.4.420.0030.04020.55
5.4.410.0030.03720.34
5.4.400.0030.03320.27
5.4.390.0070.03020.34
5.4.380.0100.02720.09
5.4.370.0100.04720.29
5.4.360.0000.03720.29
5.4.350.0000.04020.34
5.4.340.0000.04320.30
5.4.320.0070.03720.29
5.4.310.0100.03020.30
5.4.300.0030.04020.45
5.4.290.0100.04320.27
5.4.280.0070.03720.12
5.4.270.0030.03720.27
5.4.260.0030.03320.27
5.4.250.0000.04720.18
5.4.240.0100.08020.28
5.4.230.0000.06020.33
5.4.220.0100.07020.23
5.4.210.0070.07720.32
5.4.200.0100.03720.41
5.4.190.0070.07020.24
5.4.180.0000.08720.32
5.4.170.0030.07320.11
5.4.160.0100.03020.27
5.4.150.0070.04320.21
5.4.140.0070.07717.58
5.4.130.0070.03317.48
5.4.120.0100.07317.52
5.4.110.0070.05717.62
5.4.100.0200.05317.63
5.4.90.0030.04717.54
5.4.80.0070.07717.73
5.4.70.0130.06717.76
5.4.60.0000.06017.59
5.4.50.0030.05017.75
5.4.40.0030.05717.65
5.4.30.0100.07317.61
5.4.20.0000.04717.58
5.4.10.0130.07017.56
5.4.00.0000.04317.09
5.3.290.0030.04016.67
5.3.280.0030.04016.54
5.3.270.0100.07316.51
5.3.260.0100.08316.51
5.3.250.0000.07716.55
5.3.240.0070.07316.50
5.3.230.0070.05316.55
5.3.220.0000.04016.52
5.3.210.0230.03016.61
5.3.200.0070.08016.52
5.3.190.0070.06316.49
5.3.180.0070.08716.47
5.3.170.0100.04316.62
5.3.160.0000.05316.47
5.3.150.0100.07716.51
5.3.140.0030.09016.51
5.3.130.0170.03716.59
5.3.120.0130.07316.61
5.3.110.0100.06716.47
5.3.100.0030.08015.98
5.3.90.0000.05016.08
5.3.80.0070.06015.99
5.3.70.0200.05715.89
5.3.60.0100.07715.92
5.3.50.0070.05015.93
5.3.40.0130.08015.72
5.3.30.0130.03715.84
5.3.20.0130.07715.69
5.3.10.0070.06715.54
5.3.00.0000.05315.40
5.2.170.0030.06311.07
5.2.160.0100.05311.06
5.2.150.0100.03311.07
5.2.140.0070.06311.07
5.2.130.0100.05311.16
5.2.120.0030.05311.13
5.2.110.0030.03311.11
5.2.100.0130.05011.17
5.2.90.0000.06711.16
5.2.80.0030.05311.11
5.2.70.0100.02711.16
5.2.60.0030.03011.20
5.2.50.0070.05310.91
5.2.40.0030.04010.91
5.2.30.0030.03310.97
5.2.20.0100.05010.87
5.2.10.0070.06010.89
5.2.00.0100.05310.71
5.1.60.0030.04310.01
5.1.50.0000.03010.06
5.1.40.0000.0339.97
5.1.30.0000.03310.41
5.1.20.0130.05010.46
5.1.10.0030.04710.14
5.1.00.0000.06010.11
5.0.50.0030.0238.44
5.0.40.0030.0238.27
5.0.30.0070.0338.23
5.0.20.0000.0238.20
5.0.10.0070.0178.28
5.0.00.0070.0508.09
4.4.90.0000.0208.09
4.4.80.0000.0208.09
4.4.70.0000.0408.09
4.4.60.0000.0378.09
4.4.50.0000.0408.09
4.4.40.0070.0308.09
4.4.30.0000.0338.09
4.4.20.0000.0378.09
4.4.10.0070.0338.09
4.4.00.0030.0438.09
4.3.110.0030.0178.09
4.3.100.0000.0308.09
4.3.90.0070.0278.09
4.3.80.0070.0378.09
4.3.70.0100.0208.09
4.3.60.0000.0178.09
4.3.50.0030.0278.09
4.3.40.0000.0278.09
4.3.30.0000.0378.09
4.3.20.0000.0308.09
4.3.10.0030.0378.09
4.3.00.0000.0208.09

preferences:
35 ms | 400 KiB | 5 Q