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 ); foreach($classNames as $className) { print_r("-----------$className-----------\n"); var_dump(instanitateWithoutConstructorThroughUnserialize($className)); if (version_compare(PHP_VERSION, '5.4.0') >= 0) { var_dump(instanitateWithoutConstructorThroughReflection($className)); } print_r("----------------------\n"); } 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); } }

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.0160.00316.63
8.3.50.0160.00221.95
8.3.40.0180.00418.87
8.3.30.0120.00619.07
8.3.20.0080.00020.35
8.3.10.0040.00423.46
8.3.00.0060.00319.47
8.2.180.0120.00418.56
8.2.170.0040.01122.96
8.2.160.0060.00920.39
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0070.00722.26
8.2.110.0030.00722.07
8.2.100.0040.00717.84
8.2.90.0080.00019.11
8.2.80.0050.00317.97
8.2.70.0000.00917.50
8.2.60.0050.00517.80
8.2.50.0050.00318.07
8.2.40.0050.00319.94
8.2.30.0040.00418.14
8.2.20.0030.00617.74
8.2.10.0050.00318.01
8.2.00.0000.00817.82
8.1.280.0090.01625.92
8.1.270.0000.00823.79
8.1.260.0060.00326.35
8.1.250.0060.00328.09
8.1.240.0060.00323.79
8.1.230.0000.01119.17
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0050.00517.35
8.1.190.0000.01117.13
8.1.180.0000.00818.10
8.1.170.0050.00518.56
8.1.160.0050.00221.99
8.1.150.0000.00718.54
8.1.140.0030.00617.47
8.1.130.0000.00817.79
8.1.120.0040.00417.40
8.1.110.0040.00417.49
8.1.100.0000.00817.38
8.1.90.0000.00817.44
8.1.80.0060.00317.48
8.1.70.0000.00717.34
8.1.60.0030.00617.63
8.1.50.0050.00217.45
8.1.40.0050.00517.53
8.1.30.0000.00917.52
8.1.20.0080.00017.67
8.1.10.0050.00317.59
8.1.00.0040.00417.42
8.0.300.0060.00318.77
8.0.290.0070.00017.18
8.0.280.0070.00018.47
8.0.270.0080.00017.16
8.0.260.0000.00617.25
8.0.250.0000.00717.11
8.0.240.0050.00217.01
8.0.230.0030.00316.97
8.0.220.0030.00417.01
8.0.210.0030.00317.02
8.0.200.0040.00417.11
8.0.190.0070.00016.92
8.0.180.0040.00416.98
8.0.170.0020.00516.90
8.0.160.0040.00416.98
8.0.150.0070.00016.91
8.0.140.0040.00416.84
8.0.130.0080.00013.47
8.0.120.0000.00816.93
8.0.110.0040.00417.01
8.0.100.0000.00717.04
8.0.90.0040.00416.96
8.0.80.0130.01016.96
8.0.70.0020.00516.89
8.0.60.0040.00417.03
8.0.50.0040.00416.94
8.0.30.0100.01117.20
8.0.20.0070.01417.40
8.0.10.0000.00716.99
8.0.00.0160.01016.58
7.4.330.0000.00515.00
7.4.320.0040.00416.61
7.4.300.0000.00616.42
7.4.290.0000.00916.60
7.4.280.0000.00716.44
7.4.270.0030.00516.46
7.4.260.0030.00316.58
7.4.250.0000.00716.52
7.4.240.0040.00416.48
7.4.230.0070.00016.72
7.4.220.0170.01016.53
7.4.210.0090.00816.53
7.4.200.0000.00716.43
7.4.190.0030.00516.72
7.4.160.0120.01216.54
7.4.150.0110.01117.40
7.4.140.0110.01117.86
7.4.130.0120.00716.42
7.4.120.0090.00916.67
7.4.110.0090.01116.68
7.4.100.0090.01216.57
7.4.90.0100.01316.53
7.4.80.0120.01219.39
7.4.70.0150.00416.39
7.4.60.0110.00816.59
7.4.50.0040.00416.70
7.4.40.0150.00316.48
7.4.30.0130.00516.52
7.4.00.0030.01214.91
7.3.330.0030.00313.34
7.3.320.0030.00313.41
7.3.310.0050.00216.46
7.3.300.0030.00316.46
7.3.290.0060.00916.58
7.3.280.0070.01216.43
7.3.270.0070.01117.40
7.3.260.0140.00716.48
7.3.250.0120.00616.60
7.3.240.0170.00316.43
7.3.230.0070.01116.59
7.3.210.0120.00616.66
7.3.200.0090.00919.39
7.3.190.0030.01816.72
7.3.180.0070.01116.57
7.3.170.0090.00916.59
7.3.160.0080.01016.65
7.3.120.0080.01014.94
7.3.110.0070.00814.63
7.3.100.0060.00914.98
7.3.90.0070.00315.03
7.3.80.0100.00714.98
7.3.70.0030.00914.96
7.3.60.0040.01114.81
7.3.50.0000.01614.90
7.3.40.0040.01114.90
7.3.30.0060.00615.00
7.3.20.0070.01116.85
7.3.10.0070.01016.71
7.3.00.0090.00316.75
7.2.330.0120.00616.70
7.2.320.0070.01316.61
7.2.310.0060.01516.47
7.2.300.0180.00316.83
7.2.290.0170.00716.73
7.2.250.0030.01814.70
7.2.240.0090.00915.01
7.2.230.0110.00415.30
7.2.220.0070.00715.20
7.2.210.0130.00314.87
7.2.200.0090.00415.01
7.2.190.0150.00314.90
7.2.180.0040.00815.16
7.2.170.0090.00614.83
7.1.330.0070.01015.98
7.1.320.0090.00615.70
7.1.310.0090.00416.13
7.1.300.0030.00615.94
7.1.290.0040.00415.80
7.1.280.0070.00415.74
7.1.270.0030.00616.02
7.1.260.0100.00315.82
7.1.70.0000.00817.32
7.1.60.0060.01919.46
7.1.50.0000.01016.95
7.1.00.0030.07322.30
7.0.200.0080.00016.82
7.0.140.0000.07322.11
7.0.60.0070.07319.84
7.0.50.0100.06718.05
7.0.40.0230.07720.24
7.0.30.0400.04720.26
7.0.20.0270.05720.15
7.0.10.0030.04720.26
7.0.00.0030.05020.24
5.6.280.0070.07320.94
5.6.210.0030.08320.65
5.6.200.0030.04018.16
5.6.190.0100.07720.39
5.6.180.0370.06720.52
5.6.170.0230.03720.56
5.6.160.0100.05320.61
5.6.150.0030.04018.23
5.6.140.0030.06318.15
5.6.130.0000.04318.23
5.6.120.0070.04021.00
5.6.110.0130.07721.01
5.6.100.0200.02720.90
5.6.90.0130.06720.98
5.6.80.0000.04020.54
5.5.350.0000.03320.42
5.5.340.0130.07718.04
5.5.330.0030.08720.57
5.5.320.0170.06320.38
5.5.310.0270.04720.51
5.5.300.0070.08318.04
5.5.290.0070.05717.95
5.5.280.0030.08320.78
5.5.270.0100.08320.89
5.5.260.0130.08020.78
5.5.250.0100.03720.60
5.5.240.3430.03720.27
5.4.450.0530.04719.51
5.4.440.0270.04019.39
5.4.430.0700.05019.16
5.4.420.0600.04319.29
5.4.410.0730.02719.26
5.4.400.0170.04019.15
5.4.390.0870.03719.15
5.4.380.0230.05718.59
5.4.370.0230.06318.72
5.4.360.0230.04318.73
5.4.350.0200.04718.75
5.4.340.0070.06318.48
5.4.320.0080.03512.52
5.4.310.0040.04012.52
5.4.300.0100.03512.52
5.4.290.0110.06912.52
5.4.280.0160.06212.41
5.4.270.0130.04712.41
5.4.260.0120.05612.41
5.4.250.0130.06312.42
5.4.240.0140.05612.42
5.4.230.0150.08212.41
5.4.220.0200.07012.41
5.4.210.0240.06612.41
5.4.200.0140.08512.41
5.4.190.0110.06012.40
5.4.180.0110.07012.40
5.4.170.0190.06312.41
5.4.160.0090.05212.41
5.4.150.0190.07512.40
5.4.140.0120.07312.09
5.4.130.0140.07512.07
5.4.120.0350.08512.04
5.4.110.0060.04712.03
5.4.100.0120.04512.03
5.4.90.0120.04412.02
5.4.80.0150.04812.03
5.4.70.0150.05512.03
5.4.60.0210.04712.02
5.4.50.0230.07812.02
5.4.40.0110.05812.01
5.4.30.0160.06712.01
5.4.20.0120.07912.01
5.4.10.0240.08112.01
5.4.00.0100.05011.50
5.3.290.0060.03912.80
5.3.280.0130.05712.71
5.3.270.0090.05112.73
5.3.260.0120.04412.72
5.3.250.0100.06912.72
5.3.240.0250.06712.72
5.3.230.0090.05512.71
5.3.220.0100.04712.68
5.3.210.0160.06812.68
5.3.200.0110.07812.68
5.3.190.0170.08812.67
5.3.180.0170.07312.67
5.3.170.0190.07412.67
5.3.160.0100.04512.68
5.3.150.0090.06212.68
5.3.140.0140.07012.66
5.3.130.0150.08612.65
5.3.120.0170.07512.66
5.3.110.0150.07012.66
5.3.100.0110.07012.13
5.3.90.0150.07012.11
5.3.80.0090.07312.11
5.3.70.0120.07412.11
5.3.60.0210.08612.09
5.3.50.0080.08212.03
5.3.40.0080.06712.03
5.3.30.0130.09911.99
5.3.20.0130.05111.78
5.3.10.0110.05711.74
5.3.00.0240.09711.73
5.2.170.0130.0609.23
5.2.160.0140.0579.23
5.2.150.0080.0529.23
5.2.140.0220.0619.23
5.2.130.0080.0419.18
5.2.120.0080.0429.19
5.2.110.0080.0529.20
5.2.100.0070.0429.19
5.2.90.0080.0419.19
5.2.80.0060.0649.19
5.2.70.0160.0569.19
5.2.60.0090.0329.15
5.2.50.0100.0309.12
5.2.40.0080.0329.09
5.2.30.0110.0349.06
5.2.20.0050.0389.05
5.2.10.0050.0378.95
5.2.00.0080.0428.82
5.1.60.0080.0328.11
5.1.50.0040.0288.10
5.1.40.0040.0278.08
5.1.30.0140.0358.43
5.1.20.0150.0378.45
5.1.10.0090.0338.18
5.1.00.0070.0398.18
5.0.50.0090.0336.66
5.0.40.0060.0256.52
5.0.30.0060.0466.33
5.0.20.0220.0586.30
5.0.10.0090.0246.28
5.0.00.0080.0376.28
4.4.90.0030.0164.78
4.4.80.0050.0154.76
4.4.70.0040.0154.75
4.4.60.0010.0194.75
4.4.50.0060.0154.77
4.4.40.0090.0324.71
4.4.30.0020.0244.76
4.4.20.0040.0234.85
4.4.10.0140.0274.85
4.4.00.0030.0764.76
4.3.110.0070.0174.67
4.3.100.0060.0394.66
4.3.90.0030.0224.63
4.3.80.0060.0304.58
4.3.70.0090.0284.63
4.3.60.0020.0194.63
4.3.50.0050.0184.62
4.3.40.0050.0274.54
4.3.30.0030.0203.31
4.3.20.0050.0223.29
4.3.10.0030.0523.24
4.3.00.0170.02316.16

preferences:
49.03 ms | 400 KiB | 5 Q