3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class BranchDependency { private $_dependencies = []; private $_successors = []; private $_successful = false; public final function hasSuccessor(string $name) { return array_key_exists($name, $this->getSuccessors()); } public final function hasDependency(string $name) { return array_key_exists($name, $this->getDependencies()); } public final function getName() { return static::class; } public final function addDependency(BranchDependency $state) { $name = $state->getName(); if (!$this->hasDependency($name)) { $this->_dependencies[$name] = $state; $state->addSuccessor($this); } } public final function getDependencies() { return $this->_dependencies; } public final function addSuccessor(BranchDependency $state) { $name = $state->getName(); if (!$this->hasSuccessor($name)) { $this->_successors[$name] = $state; $state->addDependency($this); } } public final function getSuccessors() { return $this->_successors; } public final function wasSuccessful() { return $this->_successful; } public final function commit() { if ($this->run()) { foreach ($this->getSuccessors() as $successor) { $successor->commit(); } } } private function run() { foreach ($this->getDependencies() as $dependency) { if (!$dependency->wasSuccessful()) { return false; } } $this->_successful = $this->execute(); return $this->wasSuccessful(); } abstract protected function execute(); } final class BranchDependencyFactory { private static $instance = null; private $_instances = []; private function __construct() { } public static function Instance() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; } public function exists(string $name) { return array_key_exists($name, $this->_instances); } public function getUniqueInstance(string $name) { if (!$this->exists($name)) { $this->_instances[$name] = new $name(); } return $this->_instances[$name]; } } final class Internal extends BranchDependency { public function __construct(bool $internal) { if ($internal) { $one = BranchDependencyFactory::Instance()->getUniqueInstance(One::class); $this->addSuccessor($one); } $two = BranchDependencyFactory::Instance()->getUniqueInstance(Two::class); $this->addSuccessor($two); } public function execute() { return true; } } final class One extends BranchDependency { protected function execute() { print '#1' . PHP_EOL; return true; } } final class Two extends BranchDependency { public function __construct() { $three = BranchDependencyFactory::Instance()->getUniqueInstance(Three::class); $four = BranchDependencyFactory::Instance()->getUniqueInstance(Four::class); $this->addSuccessor($three); $this->addSuccessor($four); } protected function execute() { print '#2' . PHP_EOL; return true; } } final class Three extends BranchDependency { public function __construct() { $five = BranchDependencyFactory::Instance()->getUniqueInstance(Five::class); $this->addSuccessor($five); } protected function execute() { print '#3' . PHP_EOL; return true; } } final class Four extends BranchDependency { public function __construct() { $five = BranchDependencyFactory::Instance()->getUniqueInstance(Five::class); $this->addSuccessor($five); } protected function execute() { print '#4' . PHP_EOL; return true; } } final class Five extends BranchDependency { protected function execute() { print '#5' . PHP_EOL; return true; } } $internal = new Internal(false); $internal->commit();

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.4.20.0130.00717.68
8.4.10.0160.00017.84
8.3.150.0060.00317.23
8.3.140.0000.00820.97
8.3.130.0030.00616.72
8.3.120.0090.00020.68
8.3.110.0040.00716.72
8.3.100.0060.00316.99
8.3.90.0050.00326.77
8.3.80.0040.00416.75
8.3.70.0120.00316.63
8.3.60.0090.00916.88
8.3.50.0110.00521.28
8.3.40.0130.00718.97
8.3.30.0120.00318.83
8.3.20.0000.00818.78
8.3.10.0040.00421.80
8.3.00.0000.00918.05
8.2.270.0070.01117.36
8.2.260.0120.00617.12
8.2.250.0110.00716.68
8.2.240.0080.00016.59
8.2.230.0060.00320.94
8.2.220.0060.00324.06
8.2.210.0050.00326.77
8.2.200.0030.00618.16
8.2.190.0060.00916.63
8.2.180.0130.01016.63
8.2.170.0070.01022.96
8.2.160.0100.00319.33
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0040.01119.89
8.2.120.0050.00326.35
8.2.110.0060.00321.04
8.2.100.0060.00617.84
8.2.90.0080.00019.33
8.2.80.0040.00417.97
8.2.70.0000.00817.63
8.2.60.0000.00818.03
8.2.50.0090.00018.07
8.2.40.0000.00818.16
8.2.30.0050.00318.06
8.2.20.0050.00317.69
8.2.10.0040.00418.17
8.2.00.0070.00319.83
8.1.310.0090.00616.71
8.1.300.0030.00618.11
8.1.290.0030.00630.84
8.1.280.0080.01125.92
8.1.270.0080.00023.92
8.1.260.0080.00028.09
8.1.250.0040.00428.09
8.1.240.0060.00321.38
8.1.230.0000.01117.89
8.1.220.0000.00817.79
8.1.210.0050.00318.77
8.1.200.0000.00917.47
8.1.190.0050.00317.35
8.1.180.0040.00418.10
8.1.170.0000.00918.68
8.1.160.0030.00718.94
8.1.150.0040.00418.86
8.1.140.0040.00419.51
8.1.130.0000.00717.80
8.1.120.0040.00417.38
8.1.110.0080.00017.43
8.1.100.0000.00717.50
8.1.90.0040.00417.56
8.1.80.0040.00417.54
8.1.70.0040.00417.59
8.1.60.0000.00817.66
8.1.50.0040.00417.51
8.1.40.0000.00817.54
8.1.30.0040.00417.57
8.1.20.0040.00417.67
8.1.10.0050.00317.54
8.1.00.0000.00817.57
8.0.300.0000.00818.77
8.0.290.0040.00416.75
8.0.280.0070.00018.62
8.0.270.0030.00317.26
8.0.260.0030.00317.26
8.0.250.0070.00016.96
8.0.240.0040.00417.10
8.0.230.0050.00217.03
8.0.220.0070.00016.93
8.0.210.0070.00016.91
8.0.200.0000.00616.95
8.0.190.0040.00417.08
8.0.180.0060.00617.05
8.0.170.0000.00817.03
8.0.160.0040.00417.04
8.0.150.0040.00417.02
8.0.140.0000.00816.79
8.0.130.0000.00613.49
8.0.120.0030.00517.09
8.0.110.0030.00617.01
8.0.100.0000.00717.02
8.0.90.0050.00216.88
8.0.80.0090.00617.07
8.0.70.0050.00217.07
8.0.60.0060.00316.98
8.0.50.0080.00017.06
8.0.30.0070.01317.23
8.0.20.0090.01017.42
8.0.10.0040.00417.23
8.0.00.0090.00916.60
7.4.330.0050.00015.08
7.4.320.0030.00316.49
7.4.300.0060.00016.54
7.4.290.0070.00016.46
7.4.280.0040.00416.51
7.4.270.0000.00816.64
7.4.260.0050.00216.63
7.4.250.0000.00916.47
7.4.240.0000.00716.57
7.4.230.0000.00716.63
7.4.220.0060.01316.38
7.4.210.0100.00816.69
7.4.200.0000.00716.68
7.4.160.0060.00916.36
7.4.150.0140.00417.40
7.4.140.0170.00317.86
7.4.130.0050.01216.60
7.4.120.0080.01116.57
7.4.110.0030.01716.61
7.4.100.0090.00916.52
7.4.90.0150.00316.52
7.4.80.0120.00619.39
7.4.70.0140.00416.73
7.4.60.0050.01316.73
7.4.50.0000.01516.61
7.4.40.0070.01416.62
7.4.30.0120.00416.74
7.4.10.0090.00915.02
7.4.00.0040.01215.09
7.3.330.0000.00513.30
7.3.320.0000.00713.39
7.3.310.0000.00816.50
7.3.300.0000.00716.48
7.3.290.0030.00316.27
7.3.280.0090.00716.38
7.3.270.0150.00317.40
7.3.260.0220.00416.70
7.3.250.0120.01016.48
7.3.240.0110.00816.45
7.3.230.0120.00616.74
7.3.210.0100.00616.48
7.3.200.0060.01116.36
7.3.190.0100.00616.69
7.3.180.0140.00316.67
7.3.170.0150.00616.45
7.3.160.0130.00316.60
7.3.130.0110.01114.96
7.3.120.0070.01414.86
7.3.110.0030.01214.98
7.3.100.0030.01014.93
7.3.90.0070.00415.08
7.3.80.0030.00915.04
7.3.70.0100.00014.95
7.3.60.0060.00914.97
7.3.50.0040.00714.68
7.3.40.0030.01314.94
7.3.30.0070.00714.61
7.3.20.0110.00416.78
7.3.10.0020.00916.55
7.3.00.0080.00516.57
7.2.330.0120.00616.76
7.2.320.0130.00316.72
7.2.310.0110.00716.95
7.2.300.0090.01016.53
7.2.290.0060.01216.84
7.2.260.0060.01315.34
7.2.250.0120.00315.09
7.2.240.0030.01315.08
7.2.230.0060.01215.28
7.2.220.0130.00315.26
7.2.210.0070.00715.12
7.2.200.0060.01015.08
7.2.190.0040.01415.02
7.2.180.0150.00015.14
7.2.170.0030.00715.22
7.2.160.0080.01115.15
7.2.150.0070.00716.85
7.2.140.0090.00916.71
7.2.130.0060.00916.98
7.2.120.0080.00616.90
7.2.110.0060.00616.85
7.2.100.0070.00516.89
7.2.90.0050.01216.97
7.2.80.0080.00616.98
7.2.70.0040.00917.00
7.2.60.0120.01016.96
7.2.50.0040.00816.92
7.2.40.0060.00617.01
7.2.30.0080.00916.87
7.2.20.0070.00817.09
7.2.10.0070.01016.86
7.2.00.0060.00917.79
7.1.330.0130.00015.86
7.1.320.0040.01215.66
7.1.310.0080.00615.68
7.1.300.0070.00415.88
7.1.290.0030.00915.53
7.1.280.0070.01015.79
7.1.270.0070.00715.74
7.1.260.0100.00715.44
7.1.250.0060.00515.82
7.1.240.0030.01115.72
7.1.230.0000.01315.51
7.1.220.0000.01215.78
7.1.210.0070.00715.72
7.1.200.0020.00815.73
7.1.190.0030.00915.79
7.1.180.0080.00815.91
7.1.170.0070.00715.70
7.1.160.0030.01015.68
7.1.150.0060.00615.50
7.1.140.0060.01015.62
7.1.130.0090.00315.93
7.1.120.0100.00715.64
7.1.110.0070.00715.53
7.1.100.0030.00817.21
7.1.90.0030.00815.94
7.1.80.0030.00915.82
7.1.70.0020.00816.44
7.1.60.0080.01217.52
7.1.50.0060.00816.49
7.1.40.0070.00715.74
7.1.30.0000.01515.69
7.1.20.0090.00615.78
7.1.10.0100.00315.55
7.1.00.0080.04019.14
7.0.330.0000.00915.18
7.0.320.0040.00915.30
7.0.310.0060.00315.41
7.0.300.0000.00915.19
7.0.290.0030.01115.21
7.0.280.0030.00615.12
7.0.270.0030.00915.59
7.0.260.0000.01015.38
7.0.250.0090.00315.43
7.0.240.0030.01315.29
7.0.230.0040.00415.48
7.0.220.0070.00715.46
7.0.210.0030.01015.52
7.0.200.0030.00516.12
7.0.190.0060.00615.41
7.0.180.0000.01015.40
7.0.170.0060.00915.58
7.0.160.0090.00615.35
7.0.150.0000.01415.38
7.0.140.0040.01115.41
7.0.130.0030.00615.55
7.0.120.0060.00915.47
7.0.110.0030.00615.41
7.0.100.0070.04717.80
7.0.90.0180.04117.79
7.0.80.0070.03117.69
7.0.70.0110.02817.82
7.0.60.0070.04017.54
7.0.50.0200.03517.91
7.0.40.0080.04716.66
7.0.30.0090.03916.80
7.0.20.0030.04416.72
7.0.10.0090.02516.76
7.0.00.0040.04716.70
5.6.400.0070.01014.53
5.6.390.0040.00714.44
5.6.380.0080.00014.41
5.6.370.0000.01014.06
5.6.360.0080.00414.35
5.6.350.0070.01014.32
5.6.340.0100.00714.63
5.6.330.0080.00314.07
5.6.320.0120.00414.21
5.6.310.0030.01214.46
5.6.300.0070.00714.60
5.6.290.0030.01314.17
5.6.280.0050.04017.67
5.6.270.0070.00314.29
5.6.260.0040.00414.25
5.6.250.0080.03617.37
5.6.240.0040.04717.63
5.6.230.0080.04317.38
5.6.220.0030.03817.49
5.6.210.0060.03117.62
5.6.200.0090.02517.57
5.6.190.0050.03417.77
5.6.180.0070.04717.70
5.6.170.0090.04617.65
5.6.160.0120.03217.67
5.6.150.0060.02417.56
5.6.140.0100.03917.72
5.6.130.0100.04017.64
5.6.120.0030.05117.73
5.6.110.0050.02717.80
5.6.100.0020.02917.69
5.6.90.0050.04017.62
5.6.80.0090.02017.39
5.6.70.0080.02017.26
5.6.60.0050.04517.39
5.6.50.0030.03217.52
5.6.40.0070.04117.41
5.6.30.0080.02117.30
5.6.20.0040.02117.41
5.6.10.0080.02517.47
5.6.00.0050.02517.18
5.5.380.0080.04317.18
5.5.370.0090.04517.37
5.5.360.0100.04517.14
5.5.350.0050.04817.38
5.5.340.0070.04017.49
5.5.330.0070.02317.43
5.5.320.0050.04417.52
5.5.310.0020.02717.47
5.5.300.0030.04417.71
5.5.290.0080.03917.38
5.5.280.0070.02517.32
5.5.270.0070.04317.49
5.5.260.0020.05017.46
5.5.250.0100.04317.37
5.5.240.0050.03917.17
5.5.230.0090.03617.23
5.5.220.0050.04517.25
5.5.210.0050.03117.10
5.5.200.0040.04217.10
5.5.190.0030.04217.14
5.5.180.0030.04617.12
5.5.170.0060.01013.92
5.5.160.0050.04317.02
5.5.150.0030.03717.26
5.5.140.0010.02817.02
5.5.130.0070.03517.16
5.5.120.0080.04017.05
5.5.110.0080.04516.97
5.5.100.0070.03816.91
5.5.90.0070.02317.00
5.5.80.0090.03617.09
5.5.70.0040.03217.08
5.5.60.0070.02817.12
5.5.50.0040.02717.13
5.5.40.0050.04517.13
5.5.30.0030.04317.04
5.5.20.0100.02816.97
5.5.10.0070.04617.12
5.5.00.0140.03617.23

preferences:
30.98 ms | 403 KiB | 5 Q