3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface DataTransferObject { public static function fromParams(array $params); public function asArray(); } trait DataTransferTrait { private static $mutable = true; private function __construct(array $params) { foreach ($params as $key => $value) { $this->{'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key)))}($value); } unset($mutable); } public static function fromParams(array $params) { return new static($params); } public function asArray() { return get_object_vars($this); } public function __call($method, $args) { if ($this->mutable == true && substr($method, 0, 3) == 'set' && property_exists($this, lcfirst(substr($method, 3)))) { $this->{lcfirst(substr($method, 3))} = reset($args); } } } abstract class Command { } final class MyCommand extends Command implements DataTransferObject { use DataTransferTrait; private $foo; private $bar; private function setBar($value) { $this->bar = $value; } } $foo = MyCommand::fromParams(array('foo' => 'foo', 'bar' => 'bar', 'meh' => 'meh')); $foo->setFoo('newfoo'); $foo->setDog('dog'); var_dump($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.0100.01018.43
8.3.50.0020.01821.07
8.3.40.0070.00718.79
8.3.30.0100.01019.00
8.3.20.0040.00420.21
8.3.10.0040.00421.60
8.3.00.0040.00419.13
8.2.180.0090.00616.60
8.2.170.0030.01222.96
8.2.160.0100.00320.35
8.2.150.0150.00024.18
8.2.140.0040.00424.66
8.2.130.0000.00726.16
8.2.120.0090.00022.11
8.2.110.0060.00320.26
8.2.100.0000.01217.68
8.2.90.0000.00918.34
8.2.80.0030.00517.97
8.2.70.0050.00517.63
8.2.60.0000.00817.93
8.2.50.0030.00618.07
8.2.40.0080.00418.18
8.2.30.0000.00818.02
8.2.20.0000.00717.70
8.2.10.0050.00218.07
8.2.00.0040.00417.71
8.1.280.0140.00325.92
8.1.270.0100.00022.20
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0000.00922.20
8.1.230.0070.00420.97
8.1.220.0030.00517.74
8.1.210.0040.00418.96
8.1.200.0090.00017.25
8.1.190.0030.00617.35
8.1.180.0040.00418.10
8.1.170.0000.00818.51
8.1.160.0030.00522.03
8.1.150.0040.00418.88
8.1.140.0030.00517.54
8.1.130.0000.00817.96
8.1.120.0070.00017.52
8.1.110.0080.00017.49
8.1.100.0040.00417.41
8.1.90.0000.00717.50
8.1.80.0070.00017.50
8.1.70.0030.00317.47
8.1.60.0000.01217.45
8.1.50.0030.00517.58
8.1.40.0080.00017.51
8.1.30.0040.00417.68
8.1.20.0080.00017.53
8.1.10.0050.00317.64
8.1.00.0000.00917.45
8.0.300.0000.00720.22
8.0.290.0060.00316.75
8.0.280.0040.00418.35
8.0.270.0070.00017.20
8.0.260.0040.00417.16
8.0.250.0030.00317.05
8.0.240.0040.00417.09
8.0.230.0030.00316.94
8.0.220.0000.00717.03
8.0.210.0050.00216.93
8.0.200.0030.00316.88
8.0.190.0080.00017.11
8.0.180.0000.00716.89
8.0.170.0030.00516.91
8.0.160.0000.00716.91
8.0.150.0030.00516.76
8.0.140.0040.00416.96
8.0.130.0030.00313.32
8.0.120.0040.00416.92
8.0.110.0040.00416.85
8.0.100.0040.00416.86
8.0.90.0060.00316.99
8.0.80.0030.01616.95
8.0.70.0000.00816.86
8.0.60.0000.00716.95
8.0.50.0040.00416.98
8.0.30.0110.00817.17
8.0.20.0120.01117.40
8.0.10.0070.00016.97
8.0.00.0090.01017.06
7.4.330.0000.00515.00
7.4.320.0070.00016.51
7.4.300.0030.00316.43
7.4.290.0070.00016.64
7.4.280.0050.00516.62
7.4.270.0000.00716.51
7.4.260.0000.00716.63
7.4.250.0030.00616.60
7.4.240.0040.00316.41
7.4.230.0050.00216.52
7.4.220.0030.01416.54
7.4.210.0110.00416.70
7.4.200.0040.00416.53
7.4.160.0060.01116.54
7.4.150.0120.00617.40
7.4.140.0150.00317.86
7.4.130.0080.00916.76
7.4.120.0050.01216.53
7.4.110.0110.00716.66
7.4.100.0060.01216.55
7.4.90.0040.01416.56
7.4.80.0150.00619.39
7.4.70.0100.00716.48
7.4.60.0100.00716.51
7.4.50.0040.00416.77
7.4.40.0130.00316.72
7.4.30.0150.00616.50
7.4.00.0100.00715.25
7.3.330.0050.00013.34
7.3.320.0030.00313.46
7.3.310.0070.00016.42
7.3.300.0000.00716.25
7.3.290.0040.01116.38
7.3.280.0060.01116.37
7.3.270.0100.01017.40
7.3.260.0030.01316.29
7.3.250.0090.00816.50
7.3.240.0130.01216.59
7.3.230.0090.00716.41
7.3.210.0120.00616.46
7.3.200.0090.00919.39
7.3.190.0060.01216.50
7.3.180.0130.00416.68
7.3.170.0140.00716.56
7.3.160.0080.00816.51
7.3.10.0070.00716.61
7.3.00.0030.01016.52
7.2.330.0000.01716.92
7.2.320.0090.00916.86
7.2.310.0070.01016.70
7.2.300.0120.01216.80
7.2.290.0060.01316.74
7.2.130.0030.01017.09
7.2.120.0000.01316.89
7.2.110.0060.00917.09
7.2.100.0060.00616.61
7.2.90.0040.01116.77
7.2.80.0030.00917.13
7.2.70.0070.00416.69
7.2.60.0070.00416.88
7.2.50.0080.00416.79
7.2.40.0000.01416.94
7.2.30.0030.00916.63
7.2.20.0080.00416.56
7.2.10.0090.00316.83
7.2.00.0050.00818.12
7.1.250.0070.00315.91
7.1.200.0070.00415.85
7.1.100.0040.00817.75
7.1.70.0000.00917.11
7.1.60.0170.00719.32
7.1.50.0140.01016.87
7.1.00.0100.06322.36
7.0.200.0000.00716.78
7.0.140.0000.07322.17
7.0.60.0000.08020.03
7.0.50.0100.07717.84
7.0.40.0030.06320.20
7.0.30.0230.05320.06
7.0.20.0200.05020.19
7.0.10.0070.07720.10
7.0.00.0070.08320.21
5.6.280.0030.07721.09
5.6.210.0030.08020.76
5.6.200.0170.04318.22
5.6.190.0030.04320.61
5.6.180.0100.04720.63
5.6.170.0370.07720.45
5.6.160.0130.07720.57
5.6.150.0070.03718.15
5.6.140.0100.08018.15
5.6.130.0100.08018.23
5.6.120.0070.08720.78
5.6.110.0070.08320.98
5.6.100.0030.07320.99
5.6.90.0100.05321.12
5.6.80.0100.07320.54
5.5.350.0070.04020.43
5.5.340.0100.06018.04
5.5.330.0030.08020.27
5.5.320.0330.07720.25
5.5.310.0300.07320.25
5.5.300.0030.03717.98
5.5.290.0100.04717.97
5.5.280.0070.08320.86
5.5.270.0130.07720.98
5.5.260.0070.08720.99
5.5.250.0030.09020.63
5.5.240.0200.04320.17
5.4.450.0330.04019.48
5.4.440.0200.08019.27
5.4.430.0200.07019.47
5.4.420.0200.04319.41
5.4.410.0230.05719.44
5.4.400.0300.04718.87
5.4.390.0200.03718.88
5.4.380.0230.05319.09
5.4.370.0130.05719.24
5.4.360.0270.07319.09
5.4.350.0170.05018.99
5.4.340.0170.07719.16
5.4.320.0400.05719.08
5.4.310.0200.07019.13
5.4.300.0230.07019.31
5.4.290.0270.07018.98
5.4.280.0130.05319.19
5.4.270.0170.04319.20
5.4.260.0230.03719.06
5.4.250.0230.03319.09
5.4.240.0230.07719.25
5.4.230.0300.07019.07
5.4.220.0270.04719.13
5.4.210.0130.04318.87
5.4.200.0300.07019.30
5.4.190.0200.08018.93
5.4.180.0270.06718.96
5.4.170.0230.07019.09
5.4.160.0230.06318.97
5.4.150.0230.05719.05
5.4.140.0370.04716.41
5.4.130.0200.07016.55
5.4.120.0270.06016.39
5.4.110.0130.04316.50
5.4.100.0230.06316.56
5.4.90.0270.06316.23
5.4.80.0230.06716.55
5.4.70.0230.06016.62
5.4.60.0170.05316.27
5.4.50.0270.06316.51
5.4.40.0270.07016.50
5.4.30.0370.04716.43
5.4.20.0200.07016.43
5.4.10.0270.06016.42
5.4.00.0300.06015.82
5.3.290.0230.04314.58
5.3.280.0300.03714.58
5.3.270.0300.05714.68
5.3.260.0230.06314.72
5.3.250.0200.07314.72
5.3.240.0270.07014.63
5.3.230.0230.07314.60
5.3.220.0170.05014.57
5.3.210.0230.06014.54
5.3.200.0170.03714.59
5.3.190.0270.04714.58
5.3.180.0230.04714.46
5.3.170.0230.07314.46
5.3.160.0370.05014.55
5.3.150.0270.06714.57
5.3.140.0230.04714.55
5.3.130.0270.06014.52
5.3.120.0270.04014.47
5.3.110.0300.04714.64
5.3.100.0330.06313.95
5.3.90.0200.07314.02
5.3.80.0300.06313.93
5.3.70.0300.06314.10
5.3.60.0200.06314.13
5.3.50.0170.05014.07
5.3.40.0200.04714.06
5.3.30.0170.07013.88
5.3.20.0270.07013.78
5.3.10.0270.06313.57
5.3.00.0270.04013.86
5.2.170.0200.06012.19
5.2.160.0200.03712.19
5.2.150.0200.04312.19
5.2.140.0230.05012.19
5.2.130.0200.03712.19
5.2.120.0170.03312.19
5.2.110.0130.03312.19
5.2.100.0330.02312.19
5.2.90.0170.06012.19
5.2.80.0200.03312.19
5.2.70.0200.05312.19
5.2.60.0270.04012.19
5.2.50.0200.05012.19
5.2.40.0200.05312.19
5.2.30.0130.04312.19
5.2.20.0170.04712.19
5.2.10.0170.06312.19
5.2.00.0070.04312.19
5.1.60.0230.04312.19
5.1.50.0170.05312.19
5.1.40.0130.05312.19
5.1.30.0170.04312.19
5.1.20.0200.04312.19
5.1.10.0170.05312.19
5.1.00.0130.03312.19
5.0.50.0130.04012.19
5.0.40.0100.02312.19
5.0.30.0070.06312.19
5.0.20.0100.02712.19
5.0.10.0070.02712.19
5.0.00.0070.03012.19
4.4.90.0070.03712.19
4.4.80.0100.02012.19
4.4.70.0100.02012.19
4.4.60.0130.03012.19
4.4.50.0070.02012.19
4.4.40.0130.02712.19
4.4.30.0070.03312.19
4.4.20.0100.04012.19
4.4.10.0270.02312.19
4.4.00.0100.03012.19
4.3.110.0030.02312.19
4.3.100.0070.02012.19
4.3.90.0100.02712.19
4.3.80.0070.04712.19
4.3.70.0100.02012.19
4.3.60.0100.03312.19
4.3.50.0070.02712.19
4.3.40.0030.03712.19
4.3.30.0030.03712.19
4.3.20.0070.02012.19
4.3.10.0070.01712.19
4.3.00.0000.03012.19

preferences:
43.74 ms | 401 KiB | 5 Q