3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Object Registry: get instance of requested and optionally registered object. * * Object (instance of a class) is generater, or returned from internal cache * if it was requested and instantiated before. * * @author Time.ly Network, Inc. * @since 2.0 * @package Ai1EC * @subpackage Ai1EC.Registry */ class Ai1ec_Object_Registry { /** * @var array The internal objects cache */ private $_objects = array(); /** * @var Ai1ec_Loader The Ai1ec_Loader instance used by the registry */ private $_loader = null; /** * Get class instance. * * Return an instance for the requested key, this method has an internal * cache. * * @param string $key Name of previously registered object or parseable * class name * * @return object Instance of the requested class */ public function get( $key ) { $class_data = $this->_loader->resolve_class_name( $key ); if ( ! $class_data ) { throw new Ai1ec_Bootstrap_Exception( 'Unable to resolve class for "' . $key . '"' ); } $class_name = $class_data['c']; $instantiator = $class_data['i']; $args = array_slice( func_get_args(), 1 ); if ( isset ( $class_data['r'] ) ) { array_unshift( $args, $this ); } if ( Ai1ec_Loader::NEWINST === $instantiator ) { return $this->initiate( $class_name, $args ); } if ( Ai1ec_Loader::GLOBALINST === $instantiator ) { if ( ! isset( $this->_objects[$class_name] ) ) { // Ask the loader to load the required files to avoid autoloader $this->_loader->load( $class_name ); $this->_objects[$class_name] = $this->initiate( $class_name, $args ); } return $this->_objects[$class_name]; } // Ok it's a factory. $factory = explode( '.', $instantiator ); return $this->dispatch( $factory[0], $factory[1], $args ); } /** * Instanciate the class given the class names and arguments. * * @param string $class_name The name of the class to instanciate. * @param array $argv An array of aguments for construction. * * @return object A new instance of the requested class */ public function initiate( $class_name, array $argv = array() ) { switch ( count( $argv ) ) { case 0: return new $class_name(); case 1: return new $class_name( $argv[0] ); case 2: return new $class_name( $argv[0], $argv[1] ); case 3: return new $class_name( $argv[0], $argv[1], $argv[2] ); case 4: return new $class_name( $argv[0], $argv[1], $argv[2], $argv[3] ); case 5: return new $class_name( $argv[0], $argv[1], $argv[2], $argv[3], $argv[4] ); } $reflected = new ReflectionClass( $class_name ); return $reflected->newInstanceArgs( $argv ); } /** * A call_user_func_array alternative. * * @param string $class * @param string $method * @param array $params * * @return mixed */ public function dispatch( $class, $method, $params = array() ) { if ( empty( $class ) ) { switch ( count( $params) ) { case 0: return $method(); case 1: return $method( $params[0] ); case 2: return $method( $params[0], $params[1] ); case 3: return $method( $params[0], $params[1], $params[2] ); default: return call_user_func_array( array( $class, $method ), $params ); } } else { // get an instance of the class $class = $this->get( $class ); switch ( count( $params) ) { case 0: return $class->{$method}(); case 1: return $class->{$method}( $params[0] ); case 2: return $class->{$method}( $params[0], $params[1] ); case 3: return $class->{$method}( $params[0], $params[1], $params[2] ); default: return call_user_func_array( array( $class, $method ), $params ); } } } /** * Constructor * * Initialize the Registry * * @param Ai1ec_Loader $ai1ec_loader Instance of Ai1EC classes loader * * @return void Constructor does not return */ public function __construct( $ai1ec_loader ) { $this->_loader = $ai1ec_loader; } } class Ai1ec_Core_Callback { protected $_registry = null; protected $_registry_name = null; protected $_method = null; public function __construct( Ai1ec_Object_Registry $registry, $path, $method ) { $this->_registry = $registry; $this->_registry_name = $path; $this->_method = $method; } public function execute( array $argv ) { return $this->_registry->get( $this->_registry_name )->{$this->_method}( $argv ); } } $registry = new Ai1ec_Object_Registry(null); for($i = 0; $i < 400; $i++){ $obj = new Ai1ec_Core_Callback($registry, "bla bla bla", "method name"); }

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.40.0040.01118.88
8.3.30.0070.00719.23
8.3.20.0050.00320.16
8.3.10.0080.00023.53
8.3.00.0000.00820.58
8.2.170.0140.00722.96
8.2.160.0030.01022.26
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0030.00522.27
8.2.110.0060.00322.28
8.2.100.0040.00817.72
8.2.90.0030.00519.26
8.2.80.0060.00317.97
8.2.70.0100.00017.50
8.2.60.0080.00017.79
8.2.50.0040.00418.07
8.2.40.0090.00019.82
8.2.30.0000.00818.12
8.2.20.0050.00317.54
8.2.10.0040.00417.69
8.2.00.0040.00417.75
8.1.270.0050.00323.97
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0060.00323.85
8.1.230.0070.00419.14
8.1.220.0000.00817.76
8.1.210.0050.00318.77
8.1.200.0040.00417.35
8.1.190.0000.00917.65
8.1.180.0050.00318.10
8.1.170.0050.00518.63
8.1.160.0090.00021.99
8.1.150.0000.00718.70
8.1.140.0040.00417.46
8.1.130.0050.00317.81
8.1.120.0040.00417.38
8.1.110.0100.00017.50
8.1.100.0040.00417.37
8.1.90.0000.00717.50
8.1.80.0070.00017.46
8.1.70.0040.00417.33
8.1.60.0060.00317.68
8.1.50.0000.00817.62
8.1.40.0030.00517.64
8.1.30.0040.00417.61
8.1.20.0040.00417.62
8.1.10.0050.00317.47
8.1.00.0000.00817.41
8.0.300.0040.00418.77
8.0.290.0070.00017.05
8.0.280.0000.00818.41
8.0.270.0050.00217.23
8.0.260.0030.00316.81
8.0.250.0040.00417.03
8.0.240.0030.00316.91
8.0.230.0050.00316.91
8.0.220.0030.00316.93
8.0.210.0030.00316.87
8.0.200.0060.00017.02
8.0.190.0000.01117.05
8.0.180.0000.00716.89
8.0.170.0000.00716.96
8.0.160.0050.00316.92
8.0.150.0070.00016.86
8.0.140.0000.00816.95
8.0.130.0060.00013.50
8.0.120.0000.00816.95
8.0.110.0040.00417.04
8.0.100.0050.00316.78
8.0.90.0000.00716.92
8.0.80.0040.01416.94
8.0.70.0050.00316.94
8.0.60.0000.00717.08
8.0.50.0000.00716.91
8.0.30.0080.01117.27
8.0.20.0120.00717.40
8.0.10.0080.00017.13
8.0.00.0100.00416.75
7.4.330.0050.00015.02
7.4.320.0050.00216.63
7.4.300.0000.00616.68
7.4.290.0030.00616.60
7.4.280.0040.00416.48
7.4.270.0000.00816.55
7.4.260.0000.00716.55
7.4.250.0000.00816.55
7.4.240.0020.00516.65
7.4.230.0070.00016.67
7.4.220.0140.00416.52
7.4.210.0060.00916.65
7.4.200.0000.00716.78
7.4.190.0040.00316.55
7.4.160.0070.00716.48
7.4.150.0120.00617.40
7.4.140.0090.00717.86
7.4.130.0110.01016.52
7.4.120.0070.01016.57
7.4.110.0090.00616.33
7.4.100.0170.00316.50
7.4.90.0060.01516.54
7.4.80.0100.01316.71
7.4.70.0130.00316.57
7.4.60.0070.01016.45
7.4.50.0000.00516.51
7.4.40.0060.00922.77
7.4.30.0100.00716.58
7.4.00.0040.00814.84
7.3.330.0000.00513.21
7.3.320.0000.00513.26
7.3.310.0020.00516.43
7.3.300.0040.00416.24
7.3.290.0090.01216.38
7.3.280.0090.00616.44
7.3.270.0030.01417.40
7.3.260.0080.01216.63
7.3.250.0090.00816.50
7.3.240.0130.00316.46
7.3.230.0100.01416.43
7.3.210.0090.00916.39
7.3.200.0150.00619.39
7.3.190.0120.00816.63
7.3.180.0040.01816.46
7.3.170.0060.00916.43
7.3.160.0170.00416.45
7.3.120.0100.00614.62
7.3.10.0080.00416.50
7.3.00.0030.01016.62
7.2.330.0160.00316.69
7.2.320.0030.01416.52
7.2.310.0120.01016.78
7.2.300.0040.01516.63
7.2.290.0110.00516.73
7.2.130.0030.00816.83
7.2.120.0050.00816.73
7.2.110.0070.00716.76
7.2.100.0100.00616.67
7.2.90.0060.00716.73
7.2.80.0090.00616.79
7.2.70.0090.00616.90
7.2.60.0050.00816.75
7.2.50.0030.01316.93
7.2.40.0020.01516.64
7.2.30.0090.00416.77
7.2.20.0040.00916.85
7.2.10.0060.00816.90
7.2.00.0050.00817.56
7.1.250.0090.00915.65
7.1.100.0060.00617.96
7.1.70.0030.00717.31
7.1.60.0060.01619.29
7.1.50.0110.00316.77
7.1.00.0030.07722.35
7.0.200.0090.00616.66
7.0.140.0030.07722.14
7.0.60.0100.05319.95
7.0.50.0070.08317.93
7.0.40.0030.07020.09
7.0.30.0300.05020.10
7.0.20.0230.06320.23
7.0.10.0270.08020.09
7.0.00.0100.08720.29
5.6.280.0070.07021.02
5.6.210.0070.05720.80
5.6.200.0100.08018.22
5.6.190.0100.07020.61
5.6.180.0070.03720.61
5.6.170.0170.05020.40
5.6.160.0030.04720.51
5.6.150.0070.07318.20
5.6.140.0000.04718.29
5.6.130.0000.05318.30
5.6.120.0100.04321.05
5.6.110.0130.07021.15
5.6.100.0100.07021.05
5.6.90.0130.03021.00
5.6.80.0070.08020.57
5.6.70.3300.04020.43
5.5.350.0030.08720.56
5.5.340.0070.05017.99
5.5.330.0070.05720.46
5.5.320.0000.06720.34
5.5.310.0370.05720.30
5.5.300.0170.03717.99
5.5.290.0070.05018.06
5.5.280.0100.08320.98
5.5.270.0100.08720.88
5.5.260.0070.04020.77
5.5.250.0130.07320.61
5.5.240.0170.07020.19
5.4.450.0730.03719.41
5.4.440.0700.05319.17
5.4.430.0500.06019.57
5.4.420.0670.05719.05
5.4.410.0300.07019.24
5.4.400.0470.05018.48
5.4.390.0370.06318.78
5.4.380.0230.04718.75
5.4.370.0170.05018.74
5.4.360.0200.04718.79
5.4.350.0230.04718.60
5.4.340.0030.06318.75
5.4.320.0080.05412.53
5.4.310.0070.03712.53
5.4.300.0050.04712.53
5.4.290.0090.04712.53
5.4.280.0070.03912.43
5.4.270.0060.03712.43
5.4.260.0070.03912.43
5.4.250.0090.03512.43
5.4.240.0110.03612.43
5.4.230.0060.03812.42
5.4.220.0060.03512.42
5.4.210.0200.04112.40
5.4.200.0200.04412.41
5.4.190.0230.03912.40
5.4.180.0170.04112.39
5.4.170.0180.04012.41
5.4.160.0150.04412.41
5.4.150.0130.04812.40
5.4.140.0140.04512.08
5.4.130.0150.04412.07
5.4.120.0260.06112.03
5.4.110.0180.03912.03
5.4.100.0140.04512.02
5.4.90.0160.04212.02
5.4.80.0170.04112.02
5.4.70.0150.04212.02
5.4.60.0190.04112.02
5.4.50.0340.08412.02
5.4.40.0130.04412.01
5.4.30.0170.04112.00
5.4.20.0160.04112.00
5.4.10.0190.03912.00
5.4.00.0210.04011.49
5.3.290.0030.04312.80
5.3.280.0060.03812.73
5.3.270.0180.04812.73
5.3.260.0280.06612.72
5.3.250.0160.04612.72
5.3.240.0170.04512.73
5.3.230.0150.04712.72
5.3.220.0170.04312.68
5.3.210.0150.04912.69
5.3.200.0200.04512.68
5.3.190.0230.04712.69
5.3.180.0230.04212.68
5.3.170.0190.04612.68
5.3.160.0180.04712.68
5.3.150.0200.04212.68
5.3.140.0200.04612.68
5.3.130.0170.04612.67
5.3.120.0230.04012.67
5.3.110.0200.04212.67
5.3.100.0220.04412.15
5.3.90.0390.08512.13
5.3.80.0200.04312.13
5.3.70.0150.05312.13
5.3.60.0200.04312.10
5.3.50.0300.06812.05
5.3.40.0210.04212.06
5.3.30.0210.03912.02
5.3.20.0150.04611.80
5.3.10.0450.08011.76
5.3.00.0210.04011.75
5.2.170.0250.0839.26
5.2.160.0100.0389.26
5.2.150.0140.0349.26
5.2.140.0130.0359.25
5.2.130.0250.0529.21
5.2.120.0120.0399.21
5.2.110.0120.0389.22
5.2.100.0200.0879.22
5.2.90.0130.0369.21
5.2.80.0150.0379.21
5.2.70.0090.0399.21
5.2.60.0110.0369.16
5.2.50.0150.0389.14
5.2.40.0130.0429.11
5.2.30.0140.0359.08
5.2.20.0160.0339.08
5.2.10.0160.0348.98
5.2.00.0130.0358.83
5.1.60.0250.0478.12
5.1.50.0140.0318.12
5.1.40.0130.0298.11
5.1.30.0080.0368.46
5.1.20.0100.0338.48
5.1.10.0090.0358.20
5.1.00.0110.0328.20
5.0.50.0090.0246.66
5.0.40.0070.0256.51
5.0.30.0090.0366.32
5.0.20.0110.0216.29
5.0.10.0120.0236.27
5.0.00.0090.0376.26
4.4.90.0060.0204.77
4.4.80.0050.0214.75
4.4.70.0070.0204.75
4.4.60.0060.0214.75
4.4.50.0070.0204.77
4.4.40.0080.0284.71
4.4.30.0070.0194.76
4.4.20.0100.0154.84
4.4.10.0100.0154.85
4.4.00.0060.0314.76
4.3.110.0110.0144.66
4.3.100.0070.0184.66
4.3.90.0040.0204.64
4.3.80.0060.0304.58
4.3.70.0070.0174.63
4.3.60.0090.0154.63
4.3.50.0100.0154.63
4.3.40.0060.0304.54
4.3.30.0020.0223.30
4.3.20.0040.0193.28
4.3.10.0040.0193.25
4.3.00.0070.01013.14

preferences:
43.08 ms | 400 KiB | 5 Q