3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface DataTransferObject { public static function fromParams(array $params); public function asArray(); } trait DataTransferTrait { private $mutable; private function __construct(array $params) { foreach ($params as $key => $value) { $this->{'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key)))}($value); } unset($this->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 (isset($this->mutable) && 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.20
8.3.50.0140.00716.38
8.3.40.0070.01418.79
8.3.30.0140.00018.91
8.3.20.0070.00020.20
8.3.10.0080.00021.73
8.3.00.0040.00419.25
8.2.180.0090.00318.17
8.2.170.0110.00422.96
8.2.160.0100.01020.53
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0030.00622.20
8.2.110.0070.00322.25
8.2.100.0100.00317.78
8.2.90.0080.00019.17
8.2.80.0080.00017.97
8.2.70.0040.00417.63
8.2.60.0080.00018.04
8.2.50.0060.00318.07
8.2.40.0030.00618.18
8.2.30.0050.00217.99
8.2.20.0030.00617.71
8.2.10.0030.00518.05
8.2.00.0070.00017.79
8.1.270.0040.00422.02
8.1.260.0040.00426.35
8.1.250.0060.00328.09
8.1.240.0060.00323.64
8.1.230.0080.00420.90
8.1.220.0080.00017.76
8.1.210.0000.00818.77
8.1.200.0070.00317.35
8.1.190.0040.00417.25
8.1.180.0040.00418.10
8.1.170.0070.00318.53
8.1.160.0040.00422.00
8.1.150.0050.00218.84
8.1.140.0040.00417.37
8.1.130.0030.00317.86
8.1.120.0040.00417.55
8.1.110.0040.00417.39
8.1.100.0000.00717.48
8.1.90.0040.00417.53
8.1.80.0000.00717.52
8.1.70.0000.00817.41
8.1.60.0050.00517.60
8.1.50.0030.00617.60
8.1.40.0090.00017.42
8.1.30.0080.00017.74
8.1.20.0020.00517.52
8.1.10.0000.00817.60
8.1.00.0040.00417.53
8.0.300.0050.00318.77
8.0.290.0040.00416.75
8.0.280.0000.00718.48
8.0.270.0000.00717.21
8.0.260.0060.00017.24
8.0.250.0040.00417.01
8.0.240.0000.00816.89
8.0.230.0000.00716.87
8.0.220.0030.00316.91
8.0.210.0030.00316.91
8.0.200.0030.00316.97
8.0.190.0030.00317.00
8.0.180.0040.00416.89
8.0.170.0050.00316.94
8.0.160.0000.00716.92
8.0.150.0040.00416.88
8.0.140.0090.00016.77
8.0.130.0050.00013.37
8.0.120.0000.00816.72
8.0.110.0030.00516.84
8.0.100.0050.00316.91
8.0.90.0000.00816.77
8.0.80.0160.00616.83
8.0.70.0000.00816.91
8.0.60.0060.00316.98
8.0.50.0040.00416.98
8.0.30.0140.00517.00
8.0.20.0110.00817.40
8.0.10.0040.00417.04
8.0.00.0030.01416.72
7.4.330.0000.00515.00
7.4.320.0030.00316.63
7.4.300.0000.00716.64
7.4.290.0000.00816.65
7.4.280.0120.00416.65
7.4.270.0000.00716.54
7.4.260.0000.00716.60
7.4.250.0020.00516.57
7.4.240.0040.00316.56
7.4.230.0000.00716.70
7.4.220.0060.01216.64
7.4.210.0100.01016.59
7.4.200.0020.00516.62
7.4.160.0130.00316.41
7.4.150.0160.00517.40
7.4.140.0110.00817.86
7.4.130.0100.01016.54
7.4.120.0120.00716.53
7.4.110.0080.01116.61
7.4.100.0090.01616.54
7.4.90.0110.00716.70
7.4.80.0060.01219.39
7.4.70.0090.00616.76
7.4.60.0080.00816.52
7.4.50.0040.00416.59
7.4.40.0030.01816.56
7.4.30.0040.01416.63
7.4.00.0100.00714.96
7.3.330.0000.00513.34
7.3.320.0000.00513.34
7.3.310.0000.00716.23
7.3.300.0000.00716.20
7.3.290.0040.00416.44
7.3.280.0120.00416.33
7.3.270.0060.01217.40
7.3.260.0070.01116.68
7.3.250.0070.01116.48
7.3.240.0120.00616.66
7.3.230.0100.00716.50
7.3.210.0070.01016.45
7.3.200.0110.01119.39
7.3.190.0120.01016.59
7.3.180.0070.01016.71
7.3.170.0100.01016.57
7.3.160.0160.00316.34
7.2.330.0120.00616.86
7.2.320.0110.00716.78
7.2.310.0030.01416.70
7.2.300.0070.01416.57
7.2.290.0100.00716.86
7.2.60.0120.00316.86
7.2.00.0060.00619.64
7.1.200.0040.01115.48
7.1.100.0000.01517.99
7.1.70.0040.00417.19
7.1.60.0070.01819.32
7.1.50.0070.01516.59
7.1.00.0070.07322.42
7.0.200.0000.00916.52
7.0.140.0000.07321.95
7.0.60.0070.08319.84
7.0.50.0030.04017.92
7.0.40.0070.04020.18
7.0.30.0400.04320.21
7.0.20.0230.08320.08
7.0.10.0030.09020.24
7.0.00.0030.04320.19
5.6.280.0100.06320.79
5.6.210.0030.04720.78
5.6.200.0030.04018.24
5.6.190.0130.06020.34
5.6.180.0170.05320.48
5.6.170.0370.06720.51
5.6.160.0100.08720.41
5.6.150.0130.04718.29
5.6.140.0070.03718.15
5.6.130.0030.08018.18
5.6.120.0070.04720.80
5.6.110.0130.08321.04
5.6.100.0100.08021.02
5.6.90.0100.06721.04
5.6.80.0200.05020.40
5.5.350.0100.03720.40
5.5.340.0070.07718.04
5.5.330.0000.08020.31
5.5.320.0370.06020.34
5.5.310.0200.07320.27
5.5.300.0100.07718.08
5.5.290.0130.06317.94
5.5.280.0070.05020.79
5.5.270.0070.04320.74
5.5.260.0030.06020.91
5.5.250.0070.06020.81
5.5.240.0170.04320.22
5.4.450.0200.07319.55
5.4.440.0200.05319.30
5.4.430.0130.04719.32
5.4.420.0030.04719.41
5.4.410.0170.04019.39
5.4.400.0200.04318.98
5.4.390.0030.07718.98
5.4.380.0070.04319.06
5.4.370.1970.05018.99
5.4.360.2530.03719.07
5.4.350.2870.03718.84
5.4.340.1400.04718.95
5.4.320.2730.03719.25
5.4.310.2870.04719.17
5.4.300.3100.04319.14
5.4.290.3000.03719.22
5.4.280.2130.05019.09
5.4.270.3070.03019.06
5.4.260.2730.04018.99
5.4.250.0030.05719.18
5.4.240.0030.05318.83
5.4.230.1330.06019.13
5.4.220.1800.04319.33
5.4.210.0070.05719.14
5.4.200.0000.06319.08
5.4.190.0000.04019.12
5.4.180.1670.05719.21
5.4.170.2900.04019.29
5.4.160.3330.03319.04
5.4.150.2000.04719.20
5.4.140.0030.04716.54
5.4.130.0030.03316.40
5.4.120.0500.04016.54
5.4.110.3030.04016.61
5.4.100.1200.04716.52
5.4.90.0000.03716.29
5.4.80.1930.04016.31
5.4.70.2430.03016.62
5.4.60.1900.04016.38
5.4.50.3000.04716.18
5.4.40.0170.03716.44
5.4.30.0130.04016.51
5.4.20.0170.03716.34
5.4.10.0170.03716.23
5.4.00.0170.03715.82
5.3.290.0170.04014.64
5.3.280.0170.03714.82
5.3.270.0170.03714.66
5.3.260.0130.04014.51
5.3.250.0100.03714.61
5.3.240.0200.04714.72
5.3.230.0170.03714.68
5.3.220.0130.04714.68
5.3.210.0230.03314.48
5.3.200.0130.04014.49
5.3.190.0170.04014.50
5.3.180.0200.04314.57
5.3.170.0200.03314.64
5.3.160.0200.03714.57
5.3.150.0200.03014.64
5.3.140.0230.03314.46
5.3.130.0130.04014.77
5.3.120.0270.03014.64
5.3.110.0130.04314.45
5.3.100.0300.02714.27
5.3.90.0230.04014.03
5.3.80.0170.03714.17
5.3.70.0130.06014.10
5.3.60.0200.03313.91
5.3.50.0200.04713.93
5.3.40.0270.04014.04
5.3.30.0200.04013.96
5.3.20.0000.03713.81
5.3.10.0070.03013.57
5.3.00.0070.04013.66
5.2.170.1300.03711.23
5.2.160.1700.02311.05
5.2.150.0000.03011.13
5.2.140.0000.03011.23
5.2.130.0030.03311.06
5.2.120.0030.02711.13
5.2.110.0270.03311.03
5.2.100.0030.02711.02
5.2.90.0070.03011.11
5.2.80.0000.03011.03
5.2.70.0830.03011.10
5.2.60.1300.03011.11
5.2.50.2200.02311.01
5.2.40.1330.02711.01
5.2.30.1730.02311.01
5.2.20.0900.03311.01
5.2.10.0030.02711.01
5.2.00.0000.03011.01
5.1.60.0000.03011.01
5.1.50.0230.02311.01
5.1.40.0930.02011.01
5.1.30.1000.02711.01
5.1.20.1570.02711.01
5.1.10.1930.02011.01
5.1.00.0500.02011.01
5.0.50.0000.02011.01
5.0.40.0070.02011.01
5.0.30.0030.03311.01
5.0.20.0070.03011.01
5.0.10.0000.02711.01
5.0.00.0030.03011.01
4.4.90.0070.01011.01
4.4.80.0000.01711.01
4.4.70.0100.03711.01
4.4.60.0800.02011.01
4.4.50.0970.01011.01
4.4.40.0900.02711.01
4.4.30.0030.02311.01
4.4.20.0000.02311.01
4.4.10.0030.01711.01
4.4.00.0030.02311.01
4.3.110.0000.02011.01
4.3.100.0000.01711.01
4.3.90.0000.02011.01
4.3.80.0270.02011.01
4.3.70.0270.01311.01
4.3.60.0900.01711.01
4.3.50.0600.01311.01
4.3.40.1030.02011.01
4.3.30.0270.02311.01
4.3.20.0600.02711.01
4.3.10.0400.02011.01
4.3.00.0430.01711.01

preferences:
44.06 ms | 400 KiB | 5 Q