3v4l.org

run code in 300+ PHP versions simultaneously
<?php class HardcodedLocator { public function getFoo() { return null; } } class ConfigurableLocator { protected $services = array(); public function set( $name, $value ) { if ( isset( $this->services[$name] ) ) { throw new LogicException( 'Cannot redefine!' ); } $this->services[$name] = $value; } public function get( $name ) { if ( !isset( $this->services[$name] ) ) { throw new LogicException( 'No such service' ); } return $this->services[$name](); } } $hl = new HardcodedLocator(); $cl = new ConfigurableLocator(); $cl->set( 'foo', function() { return null; } ); $rounds = 10000; $htime = microtime( true ); for ( $i = 0; $i < $rounds; $i++ ) { $hl->getFoo(); } $htime = microtime( true ) - $htime; $ctime = microtime( true ); for ( $i = 0; $i < $rounds; $i++ ) { $cl->get( 'foo' ); } $ctime = microtime( true ) - $ctime; echo 'overhead: ' . ( ( $ctime - $htime ) / $rounds );

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.4.00.0070.00714.60
7.3.120.0070.01314.78
7.3.110.0070.01414.88
7.3.100.0120.00314.71
7.3.90.0030.01614.74
7.3.80.0030.01314.76
7.3.70.0080.00814.91
7.3.60.0060.00614.82
7.3.50.0000.01914.85
7.3.40.0090.00914.77
7.3.30.0100.00714.64
7.3.20.0100.00716.69
7.3.10.0030.01116.66
7.3.00.0050.01116.58
7.2.250.0090.00914.92
7.2.240.0070.01615.35
7.2.230.0000.01815.29
7.2.220.0030.01314.95
7.2.210.0000.01115.05
7.2.200.0100.00615.09
7.2.190.0030.01314.75
7.2.180.0050.00514.98
7.2.170.0000.01215.09
7.2.130.0070.00417.05
7.2.120.0090.01117.14
7.2.110.0030.00916.78
7.2.100.0070.01016.93
7.2.90.0100.00716.85
7.2.80.0090.00417.08
7.2.70.0060.01216.68
7.2.60.0090.00616.80
7.2.50.0030.01016.99
7.2.40.0080.00817.16
7.2.30.0040.00817.09
7.2.20.0030.01316.88
7.2.10.0030.01316.93
7.2.00.0050.00818.19
7.1.330.0090.00915.86
7.1.320.0070.01015.80
7.1.310.0040.01515.78
7.1.300.0030.01715.76
7.1.290.0000.02015.95
7.1.280.0040.01515.69
7.1.270.0030.01715.89
7.1.260.0000.01615.63
7.1.250.0030.01215.91
7.1.70.0000.00916.92
7.1.60.0030.02119.48
7.1.50.0120.00617.10
7.1.00.0100.06722.36
7.0.200.0030.00616.48
7.0.60.0070.07019.97
7.0.50.0030.08717.88
7.0.40.0170.03720.04
7.0.30.0100.04020.08
7.0.20.0370.06320.27
7.0.10.0170.07720.08
7.0.00.0100.03720.25
5.6.280.0170.06020.79
5.6.210.0070.07020.48
5.6.200.0070.04018.14
5.6.190.0200.07320.34
5.6.180.0270.08320.50
5.6.170.0230.06020.57
5.6.160.0070.04320.48
5.6.150.0000.04318.24
5.6.140.0070.05718.18
5.6.130.0170.07318.28
5.6.120.0130.07721.04
5.6.110.0070.09320.91
5.6.100.0100.05721.02
5.6.90.0100.06021.01
5.6.80.0030.04320.52
5.5.350.4370.03720.35
5.5.340.0030.05018.04
5.5.330.0070.08720.43
5.5.320.0330.07320.36
5.5.310.0270.05020.34
5.5.300.0100.08317.98
5.5.290.0070.09018.06
5.5.280.0070.09020.86
5.5.270.0170.07720.96
5.5.260.0130.08320.85
5.5.250.0100.06020.70
5.5.240.0230.04320.18

preferences:
36.41 ms | 401 KiB | 5 Q