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) { $class = new ReflectionClass($className); return unserialize( sprintf( '%s:%d:"%s":0:{}', (version_compare(PHP_VERSION, '5.4', '>') && $class->implementsInterface("Serializable") ? "C" : "O"), strlen($className), $className ) ); } function instanitateWithoutConstructorThroughReflection($className) { try { $ref = new ReflectionClass($className); return $ref->newInstanceWithoutConstructor(); } catch (Exception $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 ArrayObject {} 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)
8.3.60.0150.00616.61
8.3.50.0130.00821.92
8.3.40.0100.01018.97
8.3.30.0040.01118.96
8.3.20.0130.00620.39
8.3.10.0040.00423.53
8.3.00.0060.00319.39
8.2.180.0120.00318.41
8.2.170.0070.00722.96
8.2.160.0040.01220.54
8.2.150.0110.00424.18
8.2.140.0070.00724.66
8.2.130.0080.00026.16
8.2.120.0070.00722.17
8.2.110.0140.00320.58
8.2.100.0080.00319.64
8.2.90.0080.00019.21
8.2.80.0040.00417.97
8.2.70.0040.00717.50
8.2.60.0040.00418.04
8.2.50.0070.00318.07
8.2.40.0040.00419.78
8.2.30.0070.00018.14
8.2.20.0040.00417.81
8.2.10.0070.00018.11
8.2.00.0030.00817.81
8.1.280.0070.00725.92
8.1.270.0100.00023.97
8.1.260.0050.00326.35
8.1.250.0030.00628.09
8.1.240.0060.01223.92
8.1.230.0000.01217.42
8.1.220.0040.00417.78
8.1.210.0040.00418.77
8.1.200.0030.00617.47
8.1.190.0000.00817.22
8.1.180.0030.00719.13
8.1.170.0050.00318.42
8.1.160.0070.00022.01
8.1.150.0000.00718.57
8.1.140.0000.00717.53
8.1.130.0030.00317.72
8.1.120.0050.00317.55
8.1.110.0000.00717.43
8.1.100.0000.00817.51
8.1.90.0040.00417.51
8.1.80.0000.00717.52
8.1.70.0000.00717.48
8.1.60.0040.00417.62
8.1.50.0040.00417.44
8.1.40.0000.00717.43
8.1.30.0000.00817.68
8.1.20.0000.00817.65
8.1.10.0000.00717.61
8.1.00.0030.00617.54
8.0.300.0050.00318.77
8.0.290.0000.00816.75
8.0.280.0070.00018.51
8.0.270.0070.00017.18
8.0.260.0030.00317.27
8.0.250.0040.00416.98
8.0.240.0000.00717.07
8.0.230.0000.00717.00
8.0.220.0000.00716.99
8.0.210.0070.00016.82
8.0.200.0050.00217.04
8.0.190.0030.00516.91
8.0.180.0040.00417.00
8.0.170.0040.00417.01
8.0.160.0000.00716.94
8.0.150.0040.00416.79
8.0.140.0000.00816.89
8.0.130.0060.00313.38
8.0.120.0030.00616.95
8.0.110.0050.00216.88
8.0.100.0000.00716.92
8.0.90.0000.00816.76
8.0.80.0160.00017.00
8.0.70.0040.00416.87
8.0.60.0000.00717.01
8.0.50.0070.00017.02
8.0.30.0040.01617.09
8.0.20.0090.01117.40
8.0.10.0040.00416.96
8.0.00.0070.01417.05
7.4.330.0000.00615.02
7.4.320.0000.00716.56
7.4.300.0000.00716.59
7.4.290.0040.00416.60
7.4.280.0000.00616.50
7.4.270.0040.00416.44
7.4.260.0000.00716.55
7.4.250.0070.00016.56
7.4.240.0040.00416.59
7.4.230.0000.00716.40
7.4.220.0160.01016.72
7.4.210.0120.00516.55
7.4.200.0000.00816.59
7.4.190.0030.00316.65
7.4.160.0160.00016.59
7.4.150.0190.00017.40
7.4.140.0180.00517.86
7.4.130.0120.00516.52
7.4.120.0070.01216.48
7.4.110.0030.01516.65
7.4.100.0130.00516.53
7.4.90.0150.00316.39
7.4.80.0110.00719.39
7.4.70.0060.01216.52
7.4.60.0070.01816.47
7.4.50.0030.00316.16
7.4.40.0090.01716.50
7.4.30.0060.01116.46
7.4.00.0090.00615.11
7.3.330.0060.00013.39
7.3.320.0030.00313.41
7.3.310.0040.00416.21
7.3.300.0030.00316.28
7.3.290.0100.01016.42
7.3.280.0050.01316.40
7.3.270.0160.01017.40
7.3.260.0060.01316.61
7.3.250.0080.01016.65
7.3.240.0090.00916.66
7.3.230.0160.00016.48
7.3.210.0100.00816.70
7.3.200.0180.01819.39
7.3.190.0150.00716.36
7.3.180.0090.00716.37
7.3.170.0140.00416.51
7.3.160.0110.00616.54
7.3.120.0120.00315.18
7.2.330.0100.01016.79
7.2.320.0080.01616.77
7.2.310.0080.00716.57
7.2.300.0000.01716.55
7.2.290.0170.00816.59
7.2.00.0040.00819.52
7.1.100.0030.00618.18
7.1.70.0070.00716.93
7.1.60.0070.01519.46
7.1.50.0030.02116.95
7.1.00.0030.09022.54
7.0.200.0090.00016.88
7.0.140.0030.07722.00
7.0.60.0170.04319.82
7.0.50.0030.04017.84
7.0.40.0100.04320.22
7.0.30.0230.03320.13
7.0.20.0400.06720.30
7.0.10.0030.08720.12
7.0.00.0030.08320.08
5.6.280.0030.07321.16
5.6.210.0130.06720.73
5.6.200.0100.08318.29
5.6.190.0030.09020.42
5.6.180.0230.04720.46
5.6.170.0230.08320.53
5.6.160.0130.08320.48
5.6.150.0030.04718.20
5.6.140.0030.05018.25
5.6.130.0070.08318.14
5.6.120.0130.06020.99
5.6.110.0100.04721.16
5.6.100.0070.09021.13
5.6.90.0170.06321.02
5.6.80.0130.07720.41
5.5.350.0270.06720.43
5.5.340.0100.07717.96
5.5.330.0000.05020.37
5.5.320.0200.07720.31
5.5.310.0300.05320.20
5.5.300.0100.07317.94
5.5.290.0000.04317.91
5.5.280.0170.07020.67
5.5.270.0070.09020.78
5.5.260.0030.05720.74
5.5.250.0170.08020.70
5.5.240.0230.07720.05
5.4.450.0230.03319.55
5.4.440.0170.06719.21
5.4.430.0330.05719.30
5.4.420.0230.05019.27
5.4.410.0130.04019.23
5.4.400.0200.07319.21
5.4.390.0200.06718.87
5.4.380.0200.03719.06
5.4.370.0200.05718.87
5.4.360.0200.04719.05
5.4.350.0300.05718.95
5.4.340.0200.06019.09
5.4.320.0200.04718.87
5.4.310.0330.05718.95
5.4.300.0300.08318.86
5.4.290.0070.06319.05
5.4.280.0200.04719.14
5.4.270.0200.06319.36
5.4.260.0130.06719.06
5.4.250.0100.06319.05
5.4.240.0200.04318.94
5.4.230.0170.03719.12
5.4.220.0170.04019.30
5.4.210.0230.06319.14
5.4.200.0170.03719.07
5.4.190.0200.03319.22
5.4.180.0170.03719.07
5.4.170.0170.03719.06
5.4.160.0270.04019.18
5.4.150.0200.03718.87
5.4.140.0230.06016.44
5.4.130.0270.03316.42
5.4.120.0170.03716.46
5.4.110.0130.04316.48
5.4.100.0270.05016.52
5.4.90.0170.03716.24
5.4.80.0100.04016.28
5.4.70.0270.03016.53
5.4.60.0200.03716.25
5.4.50.0130.03716.55
5.4.40.0270.03716.27
5.4.30.0200.04316.27
5.4.20.0170.04316.25
5.4.10.0170.05316.44
5.4.00.0170.03315.95
5.3.290.0170.04014.61
5.3.280.0130.05014.65
5.3.270.0230.03314.65
5.3.260.0200.03714.55
5.3.250.0170.04314.78
5.3.240.0230.03314.88
5.3.230.0130.04314.74
5.3.220.0170.03714.58
5.3.210.0230.03014.57
5.3.200.0130.04014.52
5.3.190.0170.04014.61
5.3.180.0230.03714.57
5.3.170.0230.03014.50
5.3.160.0200.03314.51
5.3.150.0230.03014.81
5.3.140.0200.04314.55
5.3.130.0170.03714.66
5.3.120.0200.04714.80
5.3.110.0200.05714.56
5.3.100.0170.03714.03
5.3.90.0230.03014.00
5.3.80.0200.04014.27
5.3.70.0200.03314.19
5.3.60.0170.04014.06
5.3.50.0170.03313.95
5.3.40.0200.03313.90
5.3.30.0170.04713.94
5.3.20.0100.04013.84
5.3.10.0200.04313.73
5.3.00.0130.04013.59
5.2.170.0230.03311.26
5.2.160.0100.03311.31
5.2.150.0100.03311.29
5.2.140.0170.03311.17
5.2.130.0100.03011.18
5.2.120.0030.02711.03
5.2.110.0170.05711.20
5.2.100.0170.02711.02
5.2.90.0200.05711.05
5.2.80.0170.04311.26
5.2.70.0130.04011.09
5.2.60.0130.04011.07
5.2.50.0170.04311.27
5.2.40.0130.02710.94
5.2.30.0100.03011.08
5.2.20.0100.03010.95
5.2.10.0070.03310.89
5.2.00.0100.03710.61
5.1.60.0170.04310.01
5.1.50.0130.0279.95
5.1.40.0070.0309.99
5.1.30.0200.05010.45
5.1.20.0170.03310.35
5.1.10.0170.0479.99
5.1.00.0170.05010.02
5.0.50.0070.0278.63
5.0.40.0070.0238.52
5.0.30.0030.0608.25
5.0.20.0100.0208.29
5.0.10.0070.0438.25
5.0.00.0070.0378.25
4.4.90.0070.0378.25
4.4.80.0070.0338.25
4.4.70.0070.0378.25
4.4.60.0030.0308.25
4.4.50.0100.0338.25
4.4.40.0100.0238.25
4.4.30.0100.0278.25
4.4.20.0070.0378.25
4.4.10.0070.0178.25
4.4.00.0070.0278.25
4.3.110.0130.0308.25
4.3.100.0070.0208.25
4.3.90.0030.0338.25
4.3.80.0000.0438.25
4.3.70.0000.0238.25
4.3.60.0030.0108.25
4.3.50.0000.0178.25
4.3.40.0000.0238.25
4.3.30.0000.0178.25
4.3.20.0030.0178.25
4.3.10.0170.0178.25
4.3.00.0100.0338.25

preferences:
38.39 ms | 401 KiB | 5 Q