3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Acd; /** * Registry class * * Simple class to store or get elements from configuration registry */ class Registry { use ArrayAccess; /** @var array Registry configuration array */ private $data = []; /** * Class constructor * @param array $data List of values to add to the registry */ public function __construct(array $data = []) { if(!empty($data)) { foreach ($data as $key => $value) { $this->set($key, $value); } } } public function offsetSet($key, $value) { if (!$key) { $this->data[] = $value; } else { $this->data[$key] = $value; } } /** * Key to retrieve * * @param mixed $key * @return string|null */ public function offsetGet($key) { if (isset($this->data[$key])) { return $this->data[$key]; } return null; } /** * Whether a key exists * * @param mixed $key * @return bool */ public function offsetExists($key) { return isset($this->data[$key]); } /** * Key to unset * * @param mixed $key */ public function offsetUnset($key) { unset($this->data[$key]); } /** * Adds element to registry array * * @param string $key - registry Key * @param mixed $value - registry Value * @throws Exception When there is a duplicate $key */ public function set($key, $value) { if (isset($this->data[$key])) { throw new \Exception('There is already an entry for key: ' . $key); } $this->data[$key] = $value; } /** * Retrieves elements from registry array * * @param string $key * @return mixed returns a registry value * @throws Exception when no $key found */ public function get($key) { if (!isset($this->data[$key])) { throw new \Exception('There is no entry for key: ' . $key); } return $this->data[$key]; } /** * Remove an entry from the Registry * * @param string $key * @return void */ public function remove($key) { unset($this->data[$key]); } /** * Return true if value is empty for given key * * @param string $key * @return bool */ public function isEmpty($key) { return empty($this->data[$key]); } /** * Reset Registry container */ public function reset() { $this->data = []; } /** * Return total number of data elements * @return int */ public function count() { return count($this->data); } /** * IteratorAggregate interface required method * * @return \ArrayIterator */ public function getIterator() { return new \ArrayIterator($this->data); } } class Main { private $registry = null; private $service = null; private $obj = null; public function __construct() { if (!($this->registry instanceof Registry)) { $this->registry = new Registry; } } public function getService($service) { return $this->registry->get($service); } public function setService($class, array $args = null) { return $this->registry->set($class, function() use ($class, $args) { $class = $this->isValidService($class); return new $class($args); }); } private function isValidService($classname) { $classname = __NAMESPACE__ . '\\' . ucwords($classname); if(class_exists($classname)) { return $classname; } else { throw new \Exception("Invalid class name given: " . $classname); } } /** * Magic method to retrieve the Object * @param string $obj * @return object Object instance */ public function __get($obj) { $obj = $this->registry->get($obj); return $obj(); } } // Initialize main class $app = new Acd\Main(); // Start Request Service $app->setService('request');

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.0160.00616.73
8.3.50.0090.01122.05
8.3.40.0120.00318.81
8.3.30.0090.00618.61
8.3.20.0060.00320.14
8.3.10.0040.00423.66
8.3.00.0030.00519.26
8.2.180.0150.00918.43
8.2.170.0130.00722.96
8.2.160.0030.01022.31
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0080.00017.35
8.2.120.0040.00426.35
8.2.110.0060.00321.02
8.2.100.0090.00317.80
8.2.90.0040.00418.98
8.2.80.0080.00017.97
8.2.70.0030.00617.50
8.2.60.0000.00817.93
8.2.50.0000.00918.07
8.2.40.0050.00321.20
8.2.30.0040.00420.57
8.2.20.0030.00617.58
8.2.10.0040.00418.14
8.2.00.0000.00817.89
8.1.280.0070.00725.92
8.1.270.0090.00023.96
8.1.260.0080.00028.09
8.1.250.0000.00728.09
8.1.240.0000.00920.87
8.1.230.0120.00017.65
8.1.220.0000.00817.74
8.1.210.0000.00918.77
8.1.200.0080.00417.23
8.1.190.0000.00817.22
8.1.180.0040.00418.10
8.1.170.0040.00418.87
8.1.160.0000.00722.07
8.1.150.0040.00418.93
8.1.140.0040.00419.43
8.1.130.0000.00717.69
8.1.120.0040.00417.38
8.1.110.0070.00017.46
8.1.100.0020.00517.30
8.1.90.0030.00417.43
8.1.80.0040.00417.34
8.1.70.0030.00317.34
8.1.60.0030.00617.54
8.1.50.0060.00317.39
8.1.40.0000.00817.43
8.1.30.0000.00817.65
8.1.20.0060.00317.63
8.1.10.0060.00317.42
8.1.00.0030.00517.36
8.0.300.0030.00618.77
8.0.290.0020.00516.75
8.0.280.0030.00318.47
8.0.270.0000.00717.25
8.0.260.0040.00417.19
8.0.250.0000.00817.05
8.0.240.0030.00316.90
8.0.230.0070.00016.99
8.0.220.0030.00316.97
8.0.210.0030.00316.86
8.0.200.0070.00017.00
8.0.190.0000.00916.91
8.0.180.0040.00416.88
8.0.170.0050.00317.00
8.0.160.0000.00716.89
8.0.150.0050.00316.83
8.0.140.0080.00016.93
8.0.130.0030.00313.26
8.0.120.0040.00416.81
8.0.110.0050.00316.96
8.0.100.0030.00316.92
8.0.90.0030.00416.90
8.0.80.0100.01016.87
8.0.70.0050.00216.92
8.0.60.0000.00716.95
8.0.50.0040.00416.98
8.0.30.0090.00817.13
8.0.20.0100.01017.40
8.0.10.0000.00717.00
8.0.00.0130.00416.66
7.4.330.0000.00516.79
7.4.320.0030.00316.54
7.4.300.0000.00716.50
7.4.290.0000.00716.50
7.4.280.0000.00816.63
7.4.270.0030.00316.57
7.4.260.0080.00016.47
7.4.250.0060.00316.56
7.4.240.0020.00616.49
7.4.230.0080.00016.49
7.4.220.0100.00716.44
7.4.210.0160.00316.42
7.4.200.0030.00316.30
7.4.160.0090.00616.41
7.4.150.0100.01017.40
7.4.140.0170.00517.86
7.4.130.0150.00616.48
7.4.120.0100.01016.54
7.4.110.0110.00816.58
7.4.100.0150.00916.53
7.4.90.0130.01116.52
7.4.80.0120.00619.39
7.4.70.0090.00916.46
7.4.60.0090.00916.58
7.4.50.0110.00716.26
7.4.40.0140.00316.36
7.4.30.0060.01816.64
7.4.00.0070.00715.06
7.3.330.0000.00513.27
7.3.320.0000.00613.32
7.3.310.0040.00416.25
7.3.300.0030.00316.23
7.3.290.0050.00916.29
7.3.280.0090.01116.30
7.3.270.0090.00917.40
7.3.260.0030.01416.46
7.3.240.0070.01216.35
7.3.230.0100.00716.39
7.3.210.0030.01616.30
7.3.200.0080.01616.57
7.3.190.0090.00616.30
7.3.180.0030.01716.36
7.3.170.0110.00416.27
7.3.160.0110.00516.59
7.3.120.0100.00714.94
7.3.110.0080.00814.85
7.3.100.0000.01214.65
7.3.90.0110.00414.68
7.3.80.0090.00614.69
7.3.70.0030.01014.83
7.3.60.0000.01414.77
7.3.50.0080.00414.72
7.3.40.0090.00614.63
7.3.30.0060.00914.87
7.3.20.0070.00716.73
7.3.10.0110.00516.45
7.3.00.0120.00516.49
7.2.330.0060.01016.45
7.2.320.0090.00916.36
7.2.310.0100.01316.76
7.2.300.0090.00916.66
7.2.290.0070.01616.71
7.2.240.0070.01114.85
7.2.230.0090.00615.11
7.2.220.0060.01014.89
7.2.210.0060.00614.77
7.2.200.0070.00715.04
7.2.190.0140.00315.03
7.2.180.0000.01414.83
7.2.170.0060.01014.66
7.2.160.0030.00914.86
7.2.150.0030.01016.71
7.2.140.0030.00616.61
7.2.130.0070.00816.61
7.2.120.0100.00616.72
7.2.110.0100.00716.77
7.2.100.0130.00716.81
7.2.90.0100.00716.75
7.2.80.0070.01016.80
7.2.70.0070.00816.83
7.2.60.0070.00716.52
7.2.50.0060.00816.91
7.2.40.0030.01116.68
7.2.30.0170.01116.82
7.2.20.0080.00816.74
7.2.10.0030.00816.65
7.2.00.0050.00917.61
7.1.330.0070.01115.36
7.1.320.0100.00715.81
7.1.310.0130.00015.81
7.1.300.0070.00715.63
7.1.290.0000.01415.73
7.1.280.0090.00615.66
7.1.270.0030.00915.77
7.1.260.0060.00615.50
7.1.250.0070.00815.71
7.1.200.0040.00715.57
7.1.100.0030.01018.08
7.1.70.0000.00817.09
7.1.60.0070.01419.48
7.1.50.0030.01716.75
7.1.00.0030.07722.35
7.0.200.0510.00614.71
7.0.60.0100.06320.06
7.0.50.0100.06318.01
7.0.40.0270.05720.08
7.0.30.0000.05720.23
7.0.20.0130.05020.10
7.0.10.0070.05020.06
7.0.00.0100.07020.10
5.6.280.0070.04020.82
5.6.210.0070.08020.54
5.6.200.0100.06018.16
5.6.190.0000.09720.42
5.6.180.0200.08720.49
5.6.170.0300.07720.54
5.6.160.0200.06320.48
5.6.150.0000.07018.29
5.6.140.0030.03718.16
5.6.130.0030.08318.18
5.6.120.0070.06721.04
5.6.110.0070.07721.00
5.6.100.0070.07721.14
5.6.90.0130.05021.02
5.6.80.0030.04020.45
5.5.350.4270.04020.55
5.5.340.0030.05717.96
5.5.330.0130.03720.21
5.5.320.0270.05320.34
5.5.310.0300.06320.35
5.5.300.0030.06717.97
5.5.290.0070.08018.00
5.5.280.0170.04020.92
5.5.270.0030.08720.79
5.5.260.0070.08720.79
5.5.250.0100.05320.75
5.5.240.0130.05320.10

preferences:
43.97 ms | 401 KiB | 5 Q