3v4l.org

run code in 300+ PHP versions simultaneously
<?php $classNames = array( "Foo", // userland class "StdClass", // class defined by php-src, but still not considered as internal "Bar", // userland class implementing Serializable "ReflectionClass", // internal class "ArrayObject", // internal class implementing Serializable "Baz", // userland class extending internal class implementing Serializable ); function instanitateWithoutConstructorThroughUnserialize($className) { return unserialize(sprintf('O:%d:"%s":0:{}', strlen($className), $className)); } function instanitateWithoutConstructorThroughReflection($className) { try { $ref = new ReflectionClass($className); return $ref->newInstanceWithoutConstructor(); } catch (ReflectionException $e) { return $e; } } class Foo {} class Bar implements Serializable { private $data; public function serialize() { return serialize($this->data); } public function unserialize($data) { $this->data = unserialize($data); } } class Baz extends ArrayAccess {} foreach($classNames as $className) { echo "$className\n"; var_dump(instanitateWithoutConstructorThroughUnserialize($className)); if (version_compare(PHP_VERSION, '5.4.0') >= 0) { var_dump(instanitateWithoutConstructorThroughReflection($className)); } echo "\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)
5.4.290.0100.05712.52
5.4.280.0180.06912.42
5.4.270.0120.06312.42
5.4.260.0120.10212.42
5.4.250.0170.07712.42
5.4.240.0110.03712.42
5.4.230.0130.05612.41
5.4.220.0080.03912.41
5.4.210.0120.04912.41
5.4.200.0100.05112.41
5.4.190.0240.07512.41
5.4.180.0100.06812.41
5.4.170.0240.07512.42
5.4.160.0140.06412.41
5.4.150.0080.09412.41
5.4.140.0110.06712.09
5.4.130.0290.09512.08
5.4.120.0080.05112.04
5.4.110.0080.04412.04
5.4.100.0080.04812.03
5.4.90.0190.06812.04
5.4.80.0160.08612.04
5.4.70.0300.06912.03
5.4.60.0170.06012.03
5.4.50.0140.06712.02
5.4.40.0200.09312.02
5.4.30.0110.04512.01
5.4.20.0090.04912.01
5.4.10.0180.08012.01
5.4.00.0100.06911.50
5.3.280.0340.07812.71
5.3.270.0170.08012.73
5.3.260.0200.07812.71
5.3.250.0200.08312.72
5.3.240.0280.08012.72
5.3.230.0280.05812.71
5.3.220.0190.07312.68
5.3.210.0230.07712.68
5.3.200.0330.07012.68
5.3.190.0300.10712.68
5.3.180.0200.08512.67
5.3.170.0480.10712.67
5.3.160.0150.05912.68
5.3.150.0310.10712.67
5.3.140.0210.06412.66
5.3.130.0190.06912.66
5.3.120.0160.08012.66
5.3.110.0300.15912.66
5.3.100.0190.07012.13
5.3.90.0200.05912.11
5.3.80.0210.04912.10
5.3.70.0180.05912.10
5.3.60.0200.06812.09
5.3.50.0110.06112.04
5.3.40.0130.05612.04
5.3.30.0210.10211.99
5.3.20.0080.05111.78
5.3.10.0090.05211.74
5.3.00.0160.07511.73

preferences:
139.8 ms | 1394 KiB | 7 Q