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) { echo "$className\n"; var_dump(instanitateWithoutConstructorThroughUnserialize($className)); if (version_compare(PHP_VERSION, '5.4.0') >= 0) { var_dump(instanitateWithoutConstructorThroughReflection($className)); } echo "\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.70.0110.01118.55
8.3.60.0060.01316.63
8.3.50.0130.00321.87
8.3.40.0070.00718.84
8.3.30.0060.00919.04
8.3.20.0080.00020.29
8.3.10.0030.00523.70
8.3.00.0030.00719.38
8.2.180.0100.00718.25
8.2.170.0090.00622.96
8.2.160.0140.00020.39
8.2.150.0000.00824.18
8.2.140.0170.00024.66
8.2.130.0080.00026.16
8.2.120.0000.00822.28
8.2.110.0090.00022.07
8.2.100.0060.00617.97
8.2.90.0040.00419.09
8.2.80.0090.00017.97
8.2.70.0040.00417.75
8.2.60.0090.00317.68
8.2.50.0040.00418.07
8.2.40.0060.00319.94
8.2.30.0050.00218.09
8.2.20.0080.00017.64
8.2.10.0080.00018.14
8.2.00.0030.00617.70
8.1.280.0070.01025.92
8.1.270.0060.00323.79
8.1.260.0090.00026.35
8.1.250.0030.00728.09
8.1.240.0050.00523.79
8.1.230.0110.00019.13
8.1.220.0040.00417.76
8.1.210.0060.00318.77
8.1.200.0030.00717.36
8.1.190.0080.00317.25
8.1.180.0040.00418.10
8.1.170.0050.00518.36
8.1.160.0000.00721.99
8.1.150.0040.00418.63
8.1.140.0050.00317.43
8.1.130.0000.00717.85
8.1.120.0000.00817.38
8.1.110.0080.00017.38
8.1.100.0020.00517.36
8.1.90.0040.00417.51
8.1.80.0000.00817.46
8.1.70.0040.00417.41
8.1.60.0000.00917.64
8.1.50.0030.00517.58
8.1.40.0060.00617.42
8.1.30.0030.00617.67
8.1.20.0040.00417.52
8.1.10.0000.00817.56
8.1.00.0000.00717.49
8.0.300.0040.00418.77
8.0.290.0070.00017.05
8.0.280.0000.00718.39
8.0.270.0050.00217.30
8.0.260.0030.00317.34
8.0.250.0000.00717.09
8.0.240.0080.00016.93
8.0.230.0040.00416.95
8.0.220.0030.00316.97
8.0.210.0040.00416.93
8.0.200.0030.00317.00
8.0.190.0040.00417.05
8.0.180.0000.00916.89
8.0.170.0040.00416.89
8.0.160.0040.00416.86
8.0.150.0040.00416.90
8.0.140.0030.00616.97
8.0.130.0070.00013.39
8.0.120.0040.00416.95
8.0.110.0000.00716.99
8.0.100.0040.00416.88
8.0.90.0070.00016.94
8.0.80.0070.01117.03
8.0.70.0000.00816.86
8.0.60.0050.00316.82
8.0.50.0000.00716.98
8.0.30.0090.01217.06
8.0.20.0160.00417.40
8.0.10.0080.00016.97
8.0.00.0150.00717.00
7.4.330.0050.00015.00
7.4.320.0060.00316.53
7.4.300.0030.00316.52
7.4.290.0090.00316.54
7.4.280.0000.00816.50
7.4.270.0030.00316.51
7.4.260.0060.00316.52
7.4.250.0080.00016.54
7.4.240.0050.00216.52
7.4.230.0040.00416.74
7.4.220.0160.00316.66
7.4.210.0070.00716.57
7.4.200.0080.00016.73
7.4.190.0040.00416.48
7.4.160.0180.00316.40
7.4.150.0220.00517.40
7.4.140.0140.00817.86
7.4.130.0120.00516.51
7.4.120.0080.00916.44
7.4.110.0070.01416.60
7.4.100.0140.00516.71
7.4.90.0100.00916.52
7.4.80.0180.00719.39
7.4.70.0100.01316.46
7.4.60.0200.00616.49
7.4.50.0040.00416.72
7.4.40.0120.00816.64
7.4.30.0080.01116.59
7.4.00.0040.00415.17
7.3.330.0030.00313.39
7.3.320.0040.00413.33
7.3.310.0070.00016.46
7.3.300.0030.00316.30
7.3.290.0060.00916.46
7.3.280.0060.01316.41
7.3.270.0180.00717.40
7.3.260.0120.00616.39
7.3.250.0100.01216.53
7.3.240.0100.01316.57
7.3.230.0090.00916.56
7.3.210.0080.01116.52
7.3.200.0110.00819.39
7.3.190.0070.01116.67
7.3.180.0100.01416.28
7.3.170.0120.00616.55
7.3.160.0130.00316.63
7.3.120.0030.01614.69
7.2.330.0110.00816.54
7.2.320.0110.01716.73
7.2.310.0150.00316.90
7.2.300.0100.00716.76
7.2.290.0090.01516.64
7.1.70.0000.00717.04
7.1.60.0070.01719.46
7.1.50.0060.01616.98
7.1.00.0070.07322.36
7.0.200.0000.01116.79
7.0.140.0000.07022.21
7.0.60.0100.07719.88
7.0.50.0170.06317.89
7.0.40.0070.08320.09
7.0.30.0300.07720.16
7.0.20.0370.07320.34
7.0.10.0030.07720.23
7.0.00.0100.07720.23
5.6.280.0130.06321.09
5.6.210.0030.04320.56
5.6.200.0130.07318.18
5.6.190.0000.09720.66
5.6.180.0100.08320.49
5.6.170.0300.04320.71
5.6.160.0030.08320.57
5.6.150.0070.04018.18
5.6.140.0100.07018.18
5.6.130.0170.07318.17
5.6.120.0100.03721.06
5.6.110.0130.03321.03
5.6.100.0130.08321.02
5.6.90.0000.04320.99
5.6.80.0000.04320.37
5.5.350.4130.04320.40
5.5.340.0130.05317.94
5.5.330.0030.04720.29
5.5.320.0270.06020.31
5.5.310.0300.06320.41
5.5.300.0130.07017.95
5.5.290.0200.07317.98
5.5.280.0070.05320.99
5.5.270.0130.07720.69
5.5.260.0170.05720.86
5.5.250.0030.04320.71
5.5.240.0030.04720.27
5.4.450.0730.07719.59
5.4.440.0900.06319.55
5.4.430.1030.07719.33
5.4.420.0800.04319.16
5.4.410.0670.05319.46
5.4.400.0100.05718.88
5.4.390.0630.06019.12
5.4.380.0200.06318.84
5.4.370.0330.05018.60
5.4.360.0470.06018.80
5.4.350.0770.06018.80
5.4.340.0130.06718.79
5.4.320.0150.03712.52
5.4.310.0060.03812.52
5.4.300.0030.04212.52
5.4.290.0180.06612.52
5.4.280.0140.06512.42
5.4.270.0300.10412.42
5.4.260.0180.06412.41
5.4.250.0380.08812.41
5.4.240.0160.07012.41
5.4.230.0160.07912.41
5.4.220.0370.07312.41
5.4.210.0150.06912.41
5.4.200.0270.09212.41
5.4.190.0270.11412.40
5.4.180.0240.08012.40
5.4.170.0120.07612.41
5.4.160.0130.06312.41
5.4.150.0090.06912.41
5.4.140.0110.06112.09
5.4.130.0100.04912.07
5.4.120.0150.04712.03
5.4.110.0190.11612.03
5.4.100.0110.04712.03
5.4.90.0130.05212.03
5.4.80.0400.11412.03
5.4.70.0080.04412.03
5.4.60.0090.08212.03
5.4.50.0150.05512.02
5.4.40.0170.07112.00
5.4.30.0140.04512.00
5.4.20.0120.06212.01
5.4.10.0170.04112.01
5.4.00.0100.04311.50
5.3.290.0090.04712.80
5.3.280.0090.06112.71
5.3.270.0100.04112.73
5.3.260.0140.05412.72
5.3.250.0110.07012.72
5.3.240.0120.05512.72
5.3.230.0170.07712.71
5.3.220.0140.06412.68
5.3.210.0120.05512.68
5.3.200.0120.04412.68
5.3.190.0110.04412.68
5.3.180.0110.04012.67
5.3.170.0170.06712.67
5.3.160.0330.07712.67
5.3.150.0080.05712.68
5.3.140.0080.08112.66
5.3.130.0100.06412.66
5.3.120.0110.06512.65
5.3.110.0180.08312.65
5.3.100.0250.11412.13
5.3.90.0120.04312.11
5.3.80.0060.04312.11
5.3.70.0090.04812.11
5.3.60.0060.06412.09
5.3.50.0090.06612.04
5.3.40.0070.07212.03
5.3.30.0070.05211.99
5.3.20.0070.05211.77
5.3.10.0050.07511.74
5.3.00.0150.07411.72
5.2.170.0080.0419.23
5.2.160.0060.0619.23
5.2.150.0080.0679.23
5.2.140.0060.0359.23
5.2.130.0080.0429.19
5.2.120.0090.0379.18
5.2.110.0130.0709.19
5.2.100.0260.0749.19
5.2.90.0110.0429.19
5.2.80.0070.0349.18
5.2.70.0110.0459.18
5.2.60.0060.0359.14
5.2.50.0090.0409.12
5.2.40.0110.0379.09
5.2.30.0070.0499.06
5.2.20.0100.0439.05
5.2.10.0050.0458.96
5.2.00.0190.0578.82
5.1.60.0070.0448.11
5.1.50.0070.0308.10
5.1.40.0070.0438.08
5.1.30.0100.0288.43
5.1.20.0070.0298.46
5.1.10.0100.0318.18
5.1.00.0080.0478.18
5.0.50.0030.0256.66
5.0.40.0050.0196.52
5.0.30.0060.0326.33
5.0.20.0040.0276.30
5.0.10.0020.0236.28
5.0.00.0100.0346.27
4.4.90.0230.0594.78
4.4.80.0000.0274.75
4.4.70.0050.0244.75
4.4.60.0050.0184.75
4.4.50.0040.0224.77
4.4.40.0050.0344.71
4.4.30.0050.0204.76
4.4.20.0040.0184.84
4.4.10.0020.0194.85
4.4.00.0040.0304.76
4.3.110.0050.0214.67
4.3.100.0040.0224.67
4.3.90.0060.0204.64
4.3.80.0060.0414.59
4.3.70.0070.0134.63
4.3.60.0110.0244.62
4.3.50.0050.0284.63
4.3.40.0050.0364.54
4.3.30.0040.0173.30
4.3.20.0020.0193.29
4.3.10.0130.0383.24
4.3.00.0100.0239.00

preferences:
53.03 ms | 401 KiB | 5 Q