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); try { return unserialize( sprintf( '%s:%d:"%s":0:{}', (version_compare(PHP_VERSION, '5.4', '>') && $class->implementsInterface("Serializable") ? "C" : "O"), strlen($className), $className ) ); } catch (Exception $e) { return $e; } } 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.70.0150.00718.53
8.3.60.0110.01116.75
8.3.50.0140.00522.12
8.3.40.0150.00618.81
8.3.30.0140.00319.19
8.3.20.0150.00020.16
8.3.10.0130.00623.40
8.3.00.0040.00419.09
8.2.180.0090.01218.31
8.2.170.0070.00722.96
8.2.160.0120.00320.37
8.2.150.0150.00624.18
8.2.140.0120.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00422.09
8.2.110.0060.00320.52
8.2.100.0130.00019.63
8.2.90.0030.00519.27
8.2.80.0040.00417.97
8.2.70.0030.00717.38
8.2.60.0040.00418.04
8.2.50.0040.00718.07
8.2.40.0000.00819.88
8.2.30.0070.00018.30
8.2.20.0000.00817.75
8.2.10.0080.00018.22
8.2.00.0070.00317.74
8.1.280.0110.00325.92
8.1.270.0090.00023.96
8.1.260.0050.00326.35
8.1.250.0030.00728.09
8.1.240.0030.00623.96
8.1.230.0080.00317.45
8.1.220.0060.00317.74
8.1.210.0030.00518.77
8.1.200.0060.00317.35
8.1.190.0040.00417.35
8.1.180.0030.00719.13
8.1.170.0030.00618.41
8.1.160.0040.00421.96
8.1.150.0000.00818.67
8.1.140.0030.00617.46
8.1.130.0030.00317.90
8.1.120.0040.00417.37
8.1.110.0040.00417.44
8.1.100.0020.00517.48
8.1.90.0030.00617.37
8.1.80.0080.00017.39
8.1.70.0000.00717.39
8.1.60.0030.00617.50
8.1.50.0030.00517.45
8.1.40.0040.00417.47
8.1.30.0050.00317.55
8.1.20.0030.00517.63
8.1.10.0040.00417.51
8.1.00.0060.00317.55
8.0.300.0030.00618.77
8.0.290.0040.00416.75
8.0.280.0040.00418.45
8.0.270.0020.00517.23
8.0.260.0050.00217.14
8.0.250.0030.00517.04
8.0.240.0030.00316.92
8.0.230.0030.00316.99
8.0.220.0040.00416.90
8.0.210.0000.00817.03
8.0.200.0040.00417.06
8.0.190.0030.00517.07
8.0.180.0000.00717.07
8.0.170.0040.00416.87
8.0.160.0030.00316.94
8.0.150.0030.00516.89
8.0.140.0040.00416.82
8.0.130.0060.00013.34
8.0.120.0030.00516.93
8.0.110.0040.00417.01
8.0.100.0000.01016.78
8.0.90.0050.00316.80
8.0.80.0060.01517.03
8.0.70.0000.00716.93
8.0.60.0040.00416.79
8.0.50.0080.00016.96
8.0.30.0150.00717.11
8.0.20.0140.00617.42
8.0.10.0050.00317.00
8.0.00.0120.00816.91
7.4.330.0000.00515.00
7.4.320.0040.00416.51
7.4.300.0060.00016.61
7.4.290.0000.00816.46
7.4.280.0000.00716.60
7.4.270.0000.00816.45
7.4.260.0070.00416.60
7.4.250.0030.00516.58
7.4.240.0050.00416.55
7.4.230.0030.00316.34
7.4.220.0060.01316.71
7.4.210.0080.01016.50
7.4.200.0000.00716.63
7.4.190.0050.00216.47
7.4.160.0080.00816.61
7.4.150.0100.01017.40
7.4.140.0090.01517.86
7.4.130.0160.00416.43
7.4.120.0120.00616.55
7.4.110.0110.00816.71
7.4.100.0160.00616.55
7.4.90.0070.01516.61
7.4.80.0120.01219.39
7.4.70.0150.00316.63
7.4.60.0130.00616.51
7.4.50.0040.00416.65
7.4.40.0170.00716.34
7.4.30.0030.01316.58
7.4.00.0070.01015.01
7.3.330.0000.00613.46
7.3.320.0030.00313.34
7.3.310.0080.00016.39
7.3.300.0030.00316.41
7.3.290.0070.00716.41
7.3.280.0110.00916.38
7.3.270.0070.01017.40
7.3.260.0040.01316.63
7.3.250.0140.00416.54
7.3.240.0120.00616.38
7.3.230.0100.00616.39
7.3.210.0170.00416.54
7.3.200.0110.00619.39
7.3.190.0070.01116.43
7.3.180.0150.00816.59
7.3.170.0100.00716.53
7.3.160.0130.00316.54
7.3.120.0110.00514.89
7.3.110.0070.01015.14
7.3.100.0060.00914.60
7.3.90.0070.00714.84
7.3.80.0000.01514.74
7.3.70.0030.01015.04
7.3.60.0100.00314.86
7.3.50.0030.00714.86
7.3.40.0090.00315.02
7.3.30.0060.00614.94
7.3.20.0090.00616.68
7.3.10.0070.00816.78
7.3.00.0000.01216.77
7.2.330.0110.01116.71
7.2.320.0130.01016.88
7.2.310.0090.01216.56
7.2.300.0090.00916.73
7.2.290.0070.01716.65
7.2.250.0060.01315.15
7.2.240.0030.01715.16
7.2.230.0060.00615.25
7.2.220.0050.00515.11
7.2.210.0060.01015.16
7.2.200.0030.01315.12
7.2.190.0040.00815.18
7.2.180.0040.01115.22
7.2.170.0030.01315.23
7.2.130.0120.00316.98
7.2.120.0070.00717.04
7.2.110.0120.00316.79
7.2.100.0040.01117.04
7.2.90.0080.00416.75
7.2.80.0000.01116.99
7.2.70.0120.00016.95
7.2.60.0050.00716.90
7.2.50.0050.00717.04
7.2.40.0030.00916.48
7.2.30.0030.00916.81
7.2.20.0100.00617.05
7.2.10.0060.00316.72
7.2.00.0050.01018.25
7.1.330.0040.00915.75
7.1.320.0060.01016.07
7.1.310.0090.00615.57
7.1.300.0040.00715.85
7.1.290.0000.01315.77
7.1.280.0150.00015.96
7.1.270.0110.00415.77
7.1.260.0070.00415.96
7.1.250.0040.00415.88
7.1.200.0070.00415.80
7.1.100.0030.01017.78
7.1.70.0050.00317.00
7.1.60.0060.01919.46
7.1.50.0060.01016.85
7.1.00.0070.08722.43
7.0.200.0030.00516.73
7.0.140.0100.06722.04
7.0.60.0130.07720.08
7.0.50.0030.04017.91
7.0.40.0030.06720.20
7.0.30.0230.04020.29
7.0.20.0300.07320.13
7.0.10.0130.06720.09
7.0.00.0100.07720.30
5.6.280.0070.07020.92
5.6.210.0030.04320.72
5.6.200.0070.03718.15
5.6.190.0170.07720.59
5.6.180.0330.04020.58
5.6.170.0270.06720.53
5.6.160.0070.04020.55
5.6.150.0030.04718.20
5.6.140.0030.04018.20
5.6.130.0000.04718.28
5.6.120.0100.05321.13
5.6.110.0100.07721.13
5.6.100.0070.08321.13
5.6.90.0000.04320.96
5.6.80.0130.06720.44
5.5.350.0200.09020.52
5.5.340.0200.06017.96
5.5.330.0030.04320.30
5.5.320.0070.07020.33
5.5.310.0270.05020.27
5.5.300.0030.04018.05
5.5.290.0000.07018.09
5.5.280.0070.08320.83
5.5.270.0030.05320.86
5.5.260.0030.04021.00
5.5.250.0030.08320.74
5.5.240.0100.05720.22
5.4.450.0670.05319.19
5.4.440.1070.06019.39
5.4.430.0730.06319.30
5.4.420.0170.05719.60
5.4.410.0770.05719.18
5.4.400.0770.06019.12
5.4.390.0930.05719.12
5.4.380.1070.05018.77
5.4.370.0300.05718.75
5.4.360.0470.07318.53
5.4.350.0330.05018.63
5.4.340.0230.05718.80
5.4.320.0040.04512.53
5.4.310.0100.03612.52
5.4.300.0060.04412.53
5.4.290.0090.06012.52
5.4.280.0140.05512.43
5.4.270.0180.04912.43
5.4.260.0110.05812.43
5.4.250.0090.06012.43
5.4.240.0140.05612.42
5.4.230.0120.06012.42
5.4.220.0190.06712.42
5.4.210.0140.06112.42
5.4.200.0150.12412.41
5.4.190.0160.06112.41
5.4.180.0140.05612.42
5.4.170.0200.05412.42
5.4.160.0140.05212.42
5.4.150.0190.07612.41
5.4.140.0120.05212.10
5.4.130.0180.05412.09
5.4.120.0130.05212.05
5.4.110.0160.04912.05
5.4.100.0120.04912.04
5.4.90.0090.05812.04
5.4.80.0120.05512.04
5.4.70.0160.07212.04
5.4.60.0200.04812.04
5.4.50.0110.05412.04
5.4.40.0110.05112.03
5.4.30.0140.04712.03
5.4.20.0100.05312.03
5.4.10.0250.07312.02
5.4.00.0090.04811.52
5.3.290.0080.03612.80
5.3.280.0100.05012.71
5.3.270.0110.04912.72
5.3.260.0100.06412.72
5.3.250.0210.08812.71
5.3.240.0150.09212.72
5.3.230.0110.06312.71
5.3.220.0120.07112.68
5.3.210.0240.09312.68
5.3.200.0100.09112.68
5.3.190.0160.06812.68
5.3.180.0170.06912.68
5.3.170.0180.06812.68
5.3.160.0270.11212.67
5.3.150.0050.04512.67
5.3.140.0070.05212.66
5.3.130.0260.08312.66
5.3.120.0130.05912.66
5.3.110.0050.05512.66
5.3.100.0130.04612.14
5.3.90.0150.07112.13
5.3.80.0160.07312.12
5.3.70.0190.07412.12
5.3.60.0140.05412.11
5.3.50.0070.05412.05
5.3.40.0180.03912.05
5.3.30.0120.04512.01
5.3.20.0090.06211.79
5.3.10.0140.05711.76
5.3.00.0170.05811.74
5.2.170.0090.0409.24
5.2.160.0110.0339.25
5.2.150.0100.0419.25
5.2.140.0050.0399.24
5.2.130.0070.0569.20
5.2.120.0070.0559.20
5.2.110.0060.0439.21
5.2.100.0110.0639.20
5.2.90.0190.0479.21
5.2.80.0050.0389.20
5.2.70.0040.0369.20
5.2.60.0060.0329.16
5.2.50.0110.0339.13
5.2.40.0050.0369.10
5.2.30.0060.0409.08
5.2.20.0100.0309.06
5.2.10.0060.0358.96
5.2.00.0110.0368.83
5.1.60.0070.0298.11
5.1.50.0090.0518.12
5.1.40.0080.0258.09
5.1.30.0040.0428.44
5.1.20.0090.0458.46
5.1.10.0030.0338.19
5.1.00.0070.0358.19
5.0.50.0030.0296.66
5.0.40.0060.0236.52
5.0.30.0090.0456.34
5.0.20.0040.0196.30
5.0.10.0030.0216.28
5.0.00.0040.0316.27
4.4.90.0030.0184.78
4.4.80.0080.0434.76
4.4.70.0070.0184.75
4.4.60.0080.0194.75
4.4.50.0070.0374.77
4.4.40.0080.0514.71
4.4.30.0100.0384.76
4.4.20.0070.0264.84
4.4.10.0060.0434.84
4.4.00.0110.0474.76
4.3.110.0070.0384.67
4.3.100.0170.1064.66
4.3.90.0040.0214.63
4.3.80.0000.0364.58
4.3.70.0050.0204.63
4.3.60.0040.0214.63
4.3.50.0060.0214.63
4.3.40.0040.0314.53
4.3.30.0020.0253.30
4.3.20.0030.0183.27
4.3.10.0030.0223.25
4.3.00.0030.01716.16

preferences:
58.45 ms | 401 KiB | 5 Q