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 (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 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.40.0140.00719.14
8.3.30.0120.00919.25
8.3.20.0150.00420.14
8.3.10.0090.00923.61
8.3.00.0030.00619.38
8.2.170.0110.00422.96
8.2.160.0090.00920.36
8.2.150.0000.01824.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0090.00622.20
8.2.110.0090.00021.89
8.2.100.0090.00319.57
8.2.90.0030.00618.92
8.2.80.0030.00617.97
8.2.70.0040.00417.63
8.2.60.0090.00017.93
8.2.50.0100.00018.07
8.2.40.0000.00819.76
8.2.30.0000.00818.32
8.2.20.0000.00817.81
8.2.10.0030.00518.16
8.2.00.0040.00817.75
8.1.270.0110.00723.79
8.1.260.0080.00026.35
8.1.250.0030.00628.09
8.1.240.0030.00623.76
8.1.230.0040.00819.07
8.1.220.0080.00017.74
8.1.210.0050.00318.77
8.1.200.0030.00617.35
8.1.190.0080.00017.35
8.1.180.0070.00319.14
8.1.170.0080.00018.61
8.1.160.0070.00022.02
8.1.150.0000.00818.66
8.1.140.0000.00717.34
8.1.130.0050.00217.69
8.1.120.0000.00817.53
8.1.110.0030.00517.50
8.1.100.0000.00717.36
8.1.90.0000.00817.34
8.1.80.0030.00517.48
8.1.70.0030.00317.45
8.1.60.0030.00617.46
8.1.50.0040.00417.44
8.1.40.0030.00617.43
8.1.30.0000.00817.50
8.1.20.0030.00617.63
8.1.10.0040.00417.57
8.1.00.0040.00417.43
8.0.300.0050.00318.90
8.0.290.0080.00017.16
8.0.280.0080.00018.34
8.0.270.0000.00717.32
8.0.260.0030.00317.27
8.0.250.0050.00316.93
8.0.240.0000.00717.04
8.0.230.0000.00717.07
8.0.220.0000.00816.87
8.0.210.0000.00816.94
8.0.200.0000.00816.93
8.0.190.0070.00016.96
8.0.180.0000.00716.87
8.0.170.0080.00017.01
8.0.160.0050.00217.06
8.0.150.0040.00416.91
8.0.140.0000.00716.86
8.0.130.0030.00313.43
8.0.120.0040.00416.83
8.0.110.0000.00716.92
8.0.100.0030.00616.94
8.0.90.0050.00216.81
8.0.80.0080.01216.92
8.0.70.0000.00816.95
8.0.60.0040.00417.03
8.0.50.0030.00516.98
8.0.30.0110.01317.22
8.0.20.0090.01117.40
8.0.10.0030.00517.02
8.0.00.0070.01216.73
7.4.330.0020.00315.00
7.4.320.0040.00416.64
7.4.300.0000.00616.48
7.4.290.0000.00716.52
7.4.280.0000.00716.51
7.4.270.0040.00416.55
7.4.260.0030.00316.50
7.4.250.0000.00816.38
7.4.240.0020.00516.56
7.4.230.0000.00716.50
7.4.220.0110.01116.68
7.4.210.0080.00816.58
7.4.200.0070.00016.54
7.4.190.0040.00416.38
7.4.160.0000.01616.55
7.4.150.0120.01217.40
7.4.140.0160.00517.86
7.4.130.0120.00516.61
7.4.120.0090.00916.60
7.4.110.0110.00816.48
7.4.100.0040.02016.54
7.4.90.0110.00716.82
7.4.80.0150.00619.39
7.4.70.0090.00916.52
7.4.60.0110.00716.45
7.4.50.0030.00516.57
7.4.40.0190.00016.56
7.4.30.0030.01416.73
7.4.00.0030.01015.16
7.3.330.0000.00613.40
7.3.320.0030.00313.41
7.3.310.0070.00016.43
7.3.300.0050.00316.33
7.3.290.0100.01016.36
7.3.280.0090.01116.38
7.3.270.0040.01317.40
7.3.260.0170.00316.62
7.3.250.0130.00916.56
7.3.240.0120.00616.36
7.3.230.0120.00416.47
7.3.210.0060.01516.45
7.3.200.0110.00719.39
7.3.190.0130.00616.48
7.3.180.0030.01316.38
7.3.170.0110.00616.41
7.3.160.0170.00416.50
7.3.120.0110.00014.55
7.2.330.0160.00316.72
7.2.320.0100.01016.41
7.2.310.0090.01616.69
7.2.300.0130.00716.79
7.2.290.0100.01016.80
7.2.60.0030.01316.66
7.2.50.0000.01316.71
7.1.200.0030.00715.77
7.1.70.0000.00717.13
7.1.60.0040.02119.46
7.1.50.0160.00616.98
7.1.00.0130.06722.33
7.0.200.0000.01416.87
7.0.140.0070.06721.95
7.0.60.0170.06019.91
7.0.50.0170.03017.75
7.0.40.0030.09020.21
7.0.30.0230.07720.07
7.0.20.0270.04720.15
7.0.10.0000.04720.06
7.0.00.0100.07020.14
5.6.280.0070.07321.11
5.6.210.0030.04020.72
5.6.200.0000.04318.20
5.6.190.0030.06320.78
5.6.180.0300.07720.74
5.6.170.0170.04020.50
5.6.160.0070.08320.48
5.6.150.0030.07018.18
5.6.140.0100.05018.29
5.6.130.0100.07318.22
5.6.120.0070.07020.70
5.6.110.0070.08721.00
5.6.100.0170.07020.99
5.6.90.0230.06720.98
5.6.80.0130.06720.54
5.5.350.0230.07320.50
5.5.340.0030.04018.07
5.5.330.0030.07320.41
5.5.320.0030.09020.45
5.5.310.0130.05020.26
5.5.300.0130.07717.98
5.5.290.0130.07317.96
5.5.280.0100.05320.70
5.5.270.0070.08720.84
5.5.260.0070.08320.66
5.5.250.0030.04320.70
5.5.240.0130.08320.22
5.4.450.0030.03719.29
5.4.440.0200.03719.50
5.4.430.0230.04019.19
5.4.420.0630.04019.29
5.4.410.0870.02719.17
5.4.400.0800.02719.11
5.4.390.0070.03719.25
5.4.380.0400.05018.59
5.4.370.0430.05318.62
5.4.360.0270.06018.56
5.4.350.0300.07018.66
5.4.340.0400.04718.81
5.4.320.0040.03812.53
5.4.310.0110.03312.53
5.4.300.0050.03812.54
5.4.290.0110.04412.54
5.4.280.0070.04612.43
5.4.270.0070.05112.43
5.4.260.0110.04612.43
5.4.250.0050.04212.43
5.4.240.0070.03812.43
5.4.230.0120.03512.43
5.4.220.0070.05912.43
5.4.210.0090.05212.42
5.4.200.0060.04712.42
5.4.190.0060.04212.42
5.4.180.0090.05412.42
5.4.170.0150.04812.43
5.4.160.0060.03712.42
5.4.150.0040.04312.42
5.4.140.0100.06612.11
5.4.130.0180.07112.09
5.4.120.0120.05912.05
5.4.110.0090.04612.05
5.4.100.0080.04212.05
5.4.90.0080.04612.04
5.4.80.0180.06612.04
5.4.70.0100.04912.04
5.4.60.0080.04512.04
5.4.50.0080.05312.04
5.4.40.0150.04312.03
5.4.30.0540.19012.03
5.4.20.0130.03912.02
5.4.10.0120.06112.02
5.4.00.0160.11711.52
5.3.290.0080.04012.80
5.3.280.0120.06612.71
5.3.270.0100.05512.72
5.3.260.0100.05412.72
5.3.250.0220.09712.72
5.3.240.0210.06912.72
5.3.230.0150.07912.71
5.3.220.0170.07212.68
5.3.210.0130.10512.68
5.3.200.0120.06612.68
5.3.190.0160.07412.68
5.3.180.0220.09212.68
5.3.170.0120.05312.67
5.3.160.0130.05912.68
5.3.150.0180.08812.67
5.3.140.0150.07112.67
5.3.130.0130.06112.66
5.3.120.0110.07312.66
5.3.110.0170.06812.66
5.3.100.0090.05112.15
5.3.90.0080.05612.13
5.3.80.0120.05012.11
5.3.70.0180.06312.11
5.3.60.0110.04912.09
5.3.50.0120.04212.05
5.3.40.0290.09512.06
5.3.30.0100.04212.01
5.3.20.0100.06311.79
5.3.10.0140.07811.75
5.3.00.0200.07611.74
5.2.170.0150.1069.23
5.2.160.0110.0449.23
5.2.150.0120.0519.24
5.2.140.0070.0549.23
5.2.130.0070.0289.20
5.2.120.0050.0409.19
5.2.110.0090.0369.20
5.2.100.0080.0609.20
5.2.90.0110.0799.20
5.2.80.0060.0359.20
5.2.70.0060.0329.20
5.2.60.0050.0359.15
5.2.50.0050.0319.12
5.2.40.0050.0319.09
5.2.30.0100.0469.07
5.2.20.0080.0409.05
5.2.10.0060.0308.97
5.2.00.0050.0368.83
5.1.60.0050.0248.11
5.1.50.0080.0338.12
5.1.40.0040.0278.09
5.1.30.0080.0328.44
5.1.20.0030.0328.46
5.1.10.0080.0278.19
5.1.00.0050.0288.19
5.0.50.0070.0256.66
5.0.40.0060.0216.53
5.0.30.0050.0386.34
5.0.20.0040.0366.30
5.0.10.0030.0266.28
5.0.00.0030.0346.27
4.4.90.0080.0304.78
4.4.80.0210.0574.76
4.4.70.0110.0364.75
4.4.60.0090.0394.75
4.4.50.0140.0614.77
4.4.40.0100.0574.71
4.4.30.0040.0244.75
4.4.20.0130.0344.84
4.4.10.0080.0364.85
4.4.00.0150.0484.76
4.3.110.0130.0484.67
4.3.100.0180.0374.66
4.3.90.0130.0304.64
4.3.80.0060.0544.59
4.3.70.0070.0194.63
4.3.60.0050.0214.62
4.3.50.0040.0364.62
4.3.40.0110.0484.54
4.3.30.0120.0433.31
4.3.20.0000.0453.29
4.3.10.0070.0453.24
4.3.00.0070.02316.16

preferences:
49.32 ms | 400 KiB | 5 Q