3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface ArraySerializableInterface {} class Bar implements ArraySerializableInterface{ private $event = 'test'; private $test3; /** * Constructor. */ public function __construct() { $this->test3 = [ new Bar(), new Bar(), new Bar(), new Bar(), ]; } } class Foo { private $test = 'sd'; private $test2; /** * Constructor. */ public function __construct() { $this->test2 = [ new Bar(), new Bar(), new Bar(), new Bar(), ]; } public function dismount($object = null) { $object = $object?: $this; $reflectionClass = new \ReflectionClass(get_class($object)); $array =[]; foreach ($reflectionClass->getProperties() as $property) { $property->setAccessible(true); $value = $property->getValue($object); if (is_array($value)) { $this->foo($value, $property, $array); continue; } $array[$property->getName()] = $value; $property->setAccessible(false); } return $array; } private function foo($value, \ReflectionProperty $property, &$array) { foreach ($value as $name => $subValue) { if (is_object($subValue)) { $array[$property->getName()][$name] = $this->dismount($subValue); continue; } if (is_array($subValue)) { //$this->foo($subValue, $property, $array); continue; } } } } $foo = new Foo; print_r( $foo->dismount());

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.0760.01379.61
8.3.50.0640.02079.57
8.3.40.0250.02248.04
8.3.30.0320.01348.05
8.3.20.0200.00749.68
8.3.10.0200.00751.20
8.3.00.0070.00748.79
8.2.180.0590.01079.77
8.2.170.0290.01648.09
8.2.160.0140.01750.09
8.2.150.0150.01248.39
8.2.140.0170.01049.60
8.2.130.0170.00749.86
8.2.120.0060.00650.28
8.2.110.0280.00449.83
8.2.100.0300.00746.97
8.2.90.0080.01648.34
8.2.80.0120.00947.16
8.2.70.0160.01046.63
8.2.60.0110.01546.93
8.2.50.0150.00746.93
8.2.40.0100.01049.96
8.2.30.0110.01148.44
8.2.20.0160.00647.25
8.2.10.0100.01347.26
8.2.00.0090.01247.39
8.1.280.0500.02078.90
8.1.270.0170.01051.50
8.1.260.0130.00651.41
8.1.250.0200.00749.61
8.1.240.0210.01050.09
8.1.230.0350.01048.28
8.1.220.0130.01046.91
8.1.210.0190.00346.48
8.1.200.0210.00346.38
8.1.190.0250.00346.48
8.1.180.0130.01046.54
8.1.170.0130.01047.70
8.1.160.0100.01148.06
8.1.150.0170.00348.08
8.1.140.0090.01248.81
8.1.130.0100.01348.19
8.1.120.0080.01546.68
8.1.110.0140.00746.65
8.1.100.0190.00446.69
8.1.90.0070.01646.54
8.1.80.0110.01146.68
8.1.70.0170.00346.72
8.1.60.0130.01046.77
8.1.50.0170.00746.71
8.1.40.0170.00746.74
8.1.30.0060.01846.68
8.1.20.0170.00746.69
8.1.10.0230.01680.52
8.1.00.0300.01380.40
8.0.300.0260.02080.92
8.0.290.0260.01379.75
8.0.280.0190.01681.16
8.0.270.0250.01480.10
8.0.260.0350.00379.71
8.0.250.0200.01779.84
8.0.240.0270.01379.74
8.0.230.0190.01979.76
8.0.220.0170.02179.78
8.0.210.0280.00979.76
8.0.200.0240.01479.61
8.0.190.0240.02179.82
8.0.180.0270.01379.65
8.0.170.0210.02179.77
8.0.160.0200.02079.70
8.0.150.0230.02079.58
8.0.140.0240.01779.68
8.0.130.0540.017135.75
8.0.120.0310.01079.72
8.0.110.0200.01679.69
8.0.100.0370.00779.62
8.0.90.0170.02779.64
8.0.80.0530.03379.66
8.0.70.0280.01479.71
8.0.60.0320.01079.66
8.0.50.0270.01479.53
8.0.30.0590.03879.81
8.0.20.0780.03579.81
8.0.10.0190.02279.81
8.0.00.0650.04179.63
7.4.330.0190.01676.35
7.4.320.0250.01379.40
7.4.300.0240.01479.36
7.4.290.0190.02279.21
7.4.280.0270.01479.44
7.4.270.0240.01779.40
7.4.260.0560.020135.66
7.4.250.0230.01779.36
7.4.240.0240.01779.34
7.4.230.0230.01779.43
7.4.220.0820.07379.28
7.4.210.0490.04779.25
7.4.200.0230.02079.31
7.4.160.0600.04479.37
7.4.150.0580.04779.52
7.4.140.0800.04079.30
7.4.130.0870.04379.51
7.4.120.0750.04879.41
7.4.110.0650.03679.55
7.4.100.0550.04979.36
7.4.90.0680.03479.46
7.4.80.0710.03279.38
7.4.70.0720.02979.60
7.4.60.0590.04279.37
7.4.50.0370.02479.30
7.4.40.0740.02779.43
7.4.30.0650.03979.39
7.3.330.0470.027135.75
7.3.320.0580.020135.70
7.3.310.0270.01479.15
7.3.300.0190.01979.20
7.3.290.0270.01379.00
7.3.280.0700.04679.12
7.3.270.0620.04279.40
7.3.260.0700.03379.12
7.3.250.0890.04079.07
7.3.240.0680.03779.30
7.3.230.0670.03779.41
7.3.210.0620.03679.26
7.3.200.0640.03879.52
7.3.190.0670.03179.16
7.3.180.0670.05479.24
7.3.170.0710.03379.13
7.3.160.0570.04779.12
7.2.330.0660.04479.64
7.2.320.0780.03279.57
7.2.310.0820.05279.47
7.2.300.0530.05079.73
7.2.290.0610.04379.62
7.1.60.4530.03096.08
7.1.50.6530.01795.96
7.1.40.7530.02095.33
7.1.30.5170.04395.59
7.1.21.1830.03095.49
7.1.10.2600.03377.48
7.1.00.3730.03777.33
7.0.200.2370.03077.49
7.0.190.5070.02377.43
7.0.180.7270.03077.10
7.0.170.7370.04777.21
7.0.160.5630.01777.38
7.0.150.5800.03377.19
7.0.140.6500.06077.13
7.0.130.3970.04077.31
7.0.121.0970.04077.46
7.0.112.1000.02777.14
7.0.102.3470.04077.16
7.0.92.4030.02065.20
7.0.82.4570.02375.50
7.0.72.5230.02765.36
7.0.62.4900.04061.23
7.0.51.7970.03077.45
7.0.41.1870.04077.20
7.0.30.8930.04077.42
7.0.20.6870.03377.40
7.0.10.6030.05077.19
7.0.00.5570.03377.41

preferences:
54.73 ms | 400 KiB | 5 Q