3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface ArraySerializableInterface {} class Baz { private $BazEvent = 'BazEvent'; } class Bar{ private $event = 'BarEvent'; private $secendClass; /** * Constructor. */ public function __construct() { $this->secendClass = [ new Baz(), ]; } } class Foo { /** * @var string */ private $providerId; /** * @var array */ private $events; /** * Constructor. */ public function __construct($providerId) { $this->providerId = $providerId; $this->events = []; } /** * @return string */ public function getProviderId() { return $this->providerId; } /** * @return array */ public function getEvents() { return $this->events; } } function entity2array($entity, $recursionDepth = 2) { $result = array(); $class = new \ReflectionClass(get_class($entity)); foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { $methodName = $method->name; if (strpos($methodName, "get") === 0 && strlen($methodName) > 3) { $propertyName = lcfirst(substr($methodName, 3)); $value = $method->invoke($entity); if (is_object($value)) { if ($recursionDepth > 0) { $result[$propertyName] = $this->entity2array($value, $recursionDepth - 1); } else { $result[$propertyName] = "***"; //stop recursion } } else { $result[$propertyName] = $value; } } } return $result; } $foo = new Foo; var_dump( entity2array($foo));

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.0150.00618.56
8.3.50.0080.00816.25
8.3.40.0140.00718.80
8.3.30.0040.01118.77
8.3.20.0050.00220.16
8.3.10.0030.00623.27
8.3.00.0080.00020.87
8.2.180.0070.00716.50
8.2.170.0070.00722.96
8.2.160.0070.00722.26
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0080.00022.21
8.2.120.0020.00526.35
8.2.110.0030.00621.95
8.2.100.0080.00417.78
8.2.90.0040.00417.89
8.2.80.0040.00417.97
8.2.70.0000.01117.49
8.2.60.0000.00817.80
8.2.50.0000.00818.10
8.2.40.0030.00522.28
8.2.30.0070.00319.18
8.2.20.0040.00418.00
8.2.10.0070.00018.00
8.2.00.0000.00717.89
8.1.280.0070.00725.92
8.1.270.0080.00022.05
8.1.260.0000.00726.35
8.1.250.0020.00528.09
8.1.240.0090.00023.62
8.1.230.0080.00320.84
8.1.220.0000.00817.74
8.1.210.0000.00918.79
8.1.200.0070.00317.35
8.1.190.0060.00317.13
8.1.180.0000.00818.10
8.1.170.0040.00418.27
8.1.160.0000.00718.91
8.1.150.0040.00420.52
8.1.140.0030.00519.51
8.1.130.0040.00418.82
8.1.120.0050.00317.25
8.1.110.0090.00017.22
8.1.100.0040.00417.26
8.1.90.0050.00317.22
8.1.80.0000.00717.36
8.1.70.0040.00417.18
8.1.60.0040.00417.54
8.1.50.0040.00417.52
8.1.40.0000.00917.36
8.1.30.0040.00417.48
8.1.20.0000.00817.50
8.1.10.0040.00417.53
8.1.00.0030.00617.34
8.0.300.0040.00419.88
8.0.290.0070.00016.75
8.0.280.0000.00818.38
8.0.270.0000.00717.11
8.0.260.0070.00016.69
8.0.250.0040.00416.97
8.0.240.0000.00816.86
8.0.230.0000.00916.85
8.0.220.0030.00316.79
8.0.210.0040.00416.74
8.0.200.0070.00016.95
8.0.190.0060.00316.88
8.0.180.0040.00416.85
8.0.170.0040.00416.91
8.0.160.0040.00316.84
8.0.150.0030.00316.71
8.0.140.0070.00016.89
8.0.130.0030.00313.37
8.0.120.0050.00316.88
8.0.110.0040.00416.74
8.0.100.0040.00316.87
8.0.90.0040.00416.96
8.0.80.0100.00616.86
8.0.70.0000.00716.76
8.0.60.0040.00416.85
8.0.50.0040.00416.78
8.0.30.0130.00617.21
8.0.20.0090.01117.40
8.0.10.0000.00816.75
8.0.00.0130.00316.61
7.4.330.0020.00215.55
7.4.320.0060.00016.48
7.4.300.0070.00016.45
7.4.290.0060.00316.36
7.4.280.0000.00816.59
7.4.270.0030.00316.55
7.4.260.0060.00013.20
7.4.250.0070.00016.40
7.4.240.0070.00016.43
7.4.230.0030.00316.53
7.4.220.0160.00616.46
7.4.210.0090.00616.58
7.4.200.0000.00716.63
7.4.160.0100.00616.43
7.4.150.0070.01017.40
7.4.140.0140.00817.86
7.4.130.0100.00916.39
7.4.120.0110.00716.42
7.4.110.0100.00716.46
7.4.100.0070.01016.23
7.4.90.0070.01016.64
7.4.80.0060.01019.39
7.4.70.0100.00616.50
7.4.60.0060.00916.34
7.4.50.0080.00816.42
7.4.40.0070.01416.73
7.4.30.0130.00716.55
7.4.00.0030.01215.12
7.3.330.0050.00013.20
7.3.320.0000.00713.36
7.3.310.0040.00416.26
7.3.300.0040.00416.35
7.3.290.0070.00816.31
7.3.280.0090.00816.34
7.3.270.0140.00417.40
7.3.260.0080.01016.42
7.3.250.0100.00816.34
7.3.240.0080.01016.39
7.3.230.0090.00916.31
7.3.210.0130.00616.30
7.3.200.0130.00316.25
7.3.190.0100.00616.51
7.3.180.0130.00316.44
7.3.170.0090.00616.35
7.3.160.0070.01016.26
7.2.330.0100.00716.59
7.2.320.0080.00816.56
7.2.310.0120.00616.51
7.2.300.0140.00416.55
7.2.290.0080.00816.51
7.2.60.0060.01016.94
7.2.00.0040.01119.38
7.1.200.0070.00715.68
7.1.100.0030.01018.01
7.1.70.0100.00317.05
7.1.60.0370.01033.20
7.1.50.0730.00332.78
7.1.40.0500.01032.37
7.1.30.0400.00732.50
7.1.20.0470.00032.56
7.1.10.0300.00314.64
7.1.00.0270.01314.56
7.0.200.0330.00314.68
7.0.190.0530.01014.79
7.0.180.0230.01014.54
7.0.170.0200.01314.41
7.0.160.0230.00714.40
7.0.150.0300.00714.48
7.0.140.0170.01314.58
7.0.130.0200.01314.97
7.0.120.0270.00314.68
7.0.110.0230.00714.61
7.0.100.0200.00314.47
7.0.90.0200.01714.43
7.0.80.0200.01014.52
7.0.70.0200.01014.31
7.0.60.0230.01014.38
7.0.50.0400.01014.63
7.0.40.0270.00714.83
7.0.30.0170.01314.64
7.0.20.0200.01014.54
7.0.10.0270.00314.50
7.0.00.0270.00314.65

preferences:
47.76 ms | 401 KiB | 5 Q