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.0190.00318.56
8.3.50.0080.01322.00
8.3.40.0070.00718.95
8.3.30.0090.00619.18
8.3.20.0040.00420.29
8.3.10.0030.00521.82
8.3.00.0000.00819.50
8.2.180.0120.00316.88
8.2.170.0070.00722.96
8.2.160.0140.00720.33
8.2.150.0070.01424.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0050.00522.07
8.2.110.0070.00319.38
8.2.100.0040.00817.97
8.2.90.0090.00317.98
8.2.80.0050.00317.97
8.2.70.0030.00917.50
8.2.60.0090.00017.80
8.2.50.0050.00318.07
8.2.40.0000.00918.09
8.2.30.0020.00518.12
8.2.20.0050.00217.82
8.2.10.0070.00018.24
8.2.00.0000.00817.88
8.1.280.0120.00625.92
8.1.270.0030.00722.31
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0070.00320.89
8.1.230.0060.00620.98
8.1.220.0090.00017.77
8.1.210.0000.00819.08
8.1.200.0100.00017.25
8.1.190.0000.00917.48
8.1.180.0000.00718.10
8.1.170.0040.00418.59
8.1.160.0030.00622.04
8.1.150.0000.00718.95
8.1.140.0040.00417.46
8.1.130.0000.00717.89
8.1.120.0000.00817.57
8.1.110.0040.00417.52
8.1.100.0000.00717.50
8.1.90.0040.00417.51
8.1.80.0000.00717.43
8.1.70.0000.00717.48
8.1.60.0030.01017.61
8.1.50.0030.00617.48
8.1.40.0040.00417.46
8.1.30.0030.00617.63
8.1.20.0030.00617.63
8.1.10.0000.00717.68
8.1.00.0040.00417.50
8.0.300.0070.00320.23
8.0.290.0040.00416.88
8.0.280.0030.00518.45
8.0.270.0030.00317.38
8.0.260.0050.00217.33
8.0.250.0030.00517.02
8.0.240.0080.00016.98
8.0.230.0080.00017.14
8.0.220.0000.00716.91
8.0.210.0000.00717.02
8.0.200.0030.00317.09
8.0.190.0000.00816.97
8.0.180.0050.00216.93
8.0.170.0080.00016.92
8.0.160.0030.00317.04
8.0.150.0000.00717.00
8.0.140.0020.00516.85
8.0.130.0000.00513.49
8.0.120.0040.00417.00
8.0.110.0040.00416.99
8.0.100.0030.00616.88
8.0.90.0030.00617.02
8.0.80.0110.00717.05
8.0.70.0000.00816.97
8.0.60.0040.00417.09
8.0.50.0040.00416.82
8.0.30.0070.01317.22
8.0.20.0080.01217.40
8.0.10.0070.00017.09
8.0.00.0070.01016.81
7.4.330.0030.00315.00
7.4.320.0030.00316.52
7.4.300.0000.00716.41
7.4.290.0000.00816.55
7.4.280.0060.00616.57
7.4.270.0050.00316.62
7.4.260.0030.00316.47
7.4.250.0080.00016.51
7.4.240.0030.00416.56
7.4.230.0000.00716.48
7.4.220.0030.01316.58
7.4.210.0080.00616.76
7.4.200.0000.00716.70
7.4.160.0100.00716.58
7.4.150.0130.00717.40
7.4.140.0090.00917.86
7.4.130.0090.00816.51
7.4.120.0050.01216.58
7.4.110.0130.00516.62
7.4.100.0100.00616.73
7.4.90.0160.01316.50
7.4.80.0130.00719.39
7.4.70.0140.00316.75
7.4.60.0060.01316.75
7.4.50.0000.00816.63
7.4.40.0060.01316.50
7.4.30.0110.00616.68
7.4.00.0080.00815.16
7.3.330.0000.00613.18
7.3.320.0060.00013.22
7.3.310.0040.00416.27
7.3.300.0050.00216.21
7.3.290.0040.01116.40
7.3.280.0120.00416.38
7.3.270.0120.00617.40
7.3.260.0130.01016.43
7.3.250.0100.00716.56
7.3.240.0110.00716.63
7.3.230.0100.00716.63
7.3.210.0100.00716.55
7.3.200.0090.01519.39
7.3.190.0160.00616.45
7.3.180.0110.00616.55
7.3.170.0000.02116.63
7.3.160.0160.00016.60
7.2.330.0070.01116.54
7.2.320.0070.01316.55
7.2.310.0100.00716.70
7.2.300.0210.00416.83
7.2.290.0140.00316.68
7.2.60.0070.01016.60
7.2.00.0030.00919.29
7.1.200.0030.01015.83
7.1.100.0040.01117.96
7.1.70.0040.00417.19
7.1.60.0110.01519.32
7.1.50.0100.01016.99
7.1.00.0030.07722.43
7.0.200.0000.01016.53
7.0.140.0030.07321.95
7.0.60.0170.08021.69
7.0.50.0070.08717.90
7.0.40.0070.05320.24
7.0.30.0470.06720.17
7.0.20.0300.05020.23
7.0.10.0300.08020.33
7.0.00.0100.03720.15
5.6.280.0030.07321.11
5.6.210.0030.05320.68
5.6.200.0100.08318.24
5.6.190.0130.04720.77
5.6.180.0400.07020.46
5.6.170.0230.08720.47
5.6.160.0100.08320.57
5.6.150.0070.04018.14
5.6.140.0100.06018.15
5.6.130.0030.08018.16
5.6.120.0070.09321.16
5.6.110.0070.04021.00
5.6.100.0130.07721.01
5.6.90.0070.08321.00
5.6.80.0070.08020.42
5.5.350.3800.04320.35
5.5.340.0000.04317.93
5.5.330.0000.09020.27
5.5.320.0400.04320.52
5.5.310.0330.05720.34
5.5.300.0070.05317.95
5.5.290.0070.08017.96
5.5.280.0070.08020.74
5.5.270.0130.08320.89
5.5.260.0130.06720.78
5.5.250.0100.07720.70
5.5.240.0300.06020.25
5.4.450.0770.05719.61
5.4.440.0770.05319.61
5.4.430.1000.05719.46
5.4.420.0700.00019.38
5.4.410.0670.00019.30
5.4.400.0700.00019.26
5.4.390.0630.00018.98
5.4.380.0730.00019.13
5.4.370.0630.00019.13
5.4.360.0600.00019.22
5.4.350.0700.00019.17
5.4.340.0050.03712.03
5.4.320.0110.03712.52
5.4.310.0080.04312.52
5.4.300.0060.03812.52
5.4.290.0060.03812.51
5.4.280.0070.03512.41
5.4.270.0060.03612.41
5.4.260.0060.04112.41
5.4.250.0070.04512.41
5.4.240.0050.03912.41
5.4.230.0090.05212.40
5.4.220.0110.04912.40
5.4.210.0040.03712.41
5.4.200.0060.04012.40
5.4.190.0070.03712.40
5.4.180.0060.04212.40
5.4.170.0090.04412.41
5.4.160.0130.04212.41
5.4.150.0110.04612.40
5.4.140.0060.05012.09
5.4.130.0070.03412.07
5.4.120.0070.03512.04
5.4.110.0050.04512.03
5.4.100.0080.03712.03
5.4.90.0050.05012.03
5.4.80.0070.04312.03
5.4.70.0110.06812.03
5.4.60.0060.03812.02
5.4.50.0090.04012.02
5.4.40.0070.04012.02
5.4.30.0210.05012.01
5.4.20.0080.05112.01
5.4.10.0160.08212.01
5.4.00.0110.04511.50
5.3.290.0080.04612.80
5.3.280.0090.04712.71
5.3.270.0070.03812.73
5.3.260.0060.03912.72
5.3.250.0070.03612.72
5.3.240.0100.04112.72
5.3.230.0090.04112.71
5.3.220.0070.03612.68
5.3.210.0070.03912.68
5.3.200.0060.03712.68
5.3.190.0070.03712.68
5.3.180.0070.03612.67
5.3.170.0050.03712.67
5.3.160.0090.03612.67
5.3.150.0070.03812.68
5.3.140.0060.03612.66
5.3.130.0080.04012.66
5.3.120.0040.04212.66
5.3.110.0040.04212.66
5.3.100.0050.03812.13
5.3.90.0060.03812.11
5.3.80.0050.03712.09
5.3.70.0080.03512.09
5.3.60.0080.03512.09
5.3.50.0060.03512.03
5.3.40.0080.03512.03
5.3.30.0070.03611.99
5.3.20.0100.03011.77
5.3.10.0060.03411.73
5.3.00.0070.03911.72
5.2.170.0110.0329.23
5.2.160.0030.0349.23
5.2.150.0040.0449.23
5.2.140.0040.0339.21
5.2.130.0050.0349.18
5.2.120.0060.0329.18
5.2.110.0070.0289.19
5.2.100.0070.0269.18
5.2.90.0080.0409.18
5.2.80.0040.0319.18
5.2.70.0070.0329.17
5.2.60.0060.0299.14
5.2.50.0060.0439.11
5.2.40.0040.0339.08
5.2.30.0030.0309.05
5.2.20.0020.0309.04
5.2.10.0030.0348.95
5.2.00.0050.0408.81
5.1.60.0070.0308.09
5.1.50.0050.0268.09
5.1.40.0040.0288.07
5.1.30.0070.0358.42
5.1.20.0100.0368.45
5.1.10.0080.0308.18
5.1.00.0060.0308.18
5.0.50.0090.0366.64
5.0.40.0030.0236.50
5.0.30.0070.0336.31
5.0.20.0220.0846.28
5.0.10.0050.0296.26
5.0.00.0060.0396.25
4.4.90.0110.0274.78
4.4.80.0040.0144.75
4.4.70.0050.0154.75
4.4.60.0040.0164.75
4.4.50.0040.0204.77
4.4.40.0030.0274.70
4.4.30.0020.0194.76
4.4.20.0050.0164.84
4.4.10.0050.0164.85
4.4.00.0030.0304.76
4.3.110.0040.0184.67
4.3.100.0040.0154.66
4.3.90.0010.0214.63
4.3.80.0070.0224.59
4.3.70.0020.0194.63
4.3.60.0040.0164.63
4.3.50.0020.0164.63
4.3.40.0030.0284.54
4.3.30.0020.0173.28
4.3.20.0040.0143.26
4.3.10.0010.0203.22
4.3.00.0170.0277.21

preferences:
38.5 ms | 401 KiB | 5 Q