3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface DataTransferObject { public static function fromParams(array $params); public function asArray(); } trait ImmutableFromParams { private $mutable = true; 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 { use ImmutableFromParams; } final class MyCommand extends Command implements DataTransferObject { protected $foo; protected $bar; protected 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.0140.00718.30
8.3.50.0060.01621.97
8.3.40.0120.00318.68
8.3.30.0170.00318.93
8.3.20.0000.00720.16
8.3.10.0030.00623.66
8.3.00.0080.00019.25
8.2.180.0070.01416.50
8.2.170.0140.00022.96
8.2.160.0140.00020.52
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0030.00622.24
8.2.110.0120.00921.20
8.2.100.0040.00717.68
8.2.90.0080.00017.65
8.2.80.0040.00417.97
8.2.70.0120.00017.63
8.2.60.0060.00317.93
8.2.50.0030.00518.07
8.2.40.0040.00718.02
8.2.30.0040.00417.96
8.2.20.0000.00817.65
8.2.10.0000.00818.07
8.2.00.0040.00417.58
8.1.280.0110.00725.92
8.1.270.0000.00921.92
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0030.00722.00
8.1.230.0040.00722.67
8.1.220.0080.00017.76
8.1.210.0090.00218.77
8.1.200.0030.00617.35
8.1.190.0050.00517.35
8.1.180.0080.00018.10
8.1.170.0030.00918.59
8.1.160.0000.00821.92
8.1.150.0050.00218.86
8.1.140.0000.00917.48
8.1.130.0030.00317.85
8.1.120.0000.00717.50
8.1.110.0080.00017.52
8.1.100.0070.00017.41
8.1.90.0000.00717.48
8.1.80.0050.00217.37
8.1.70.0030.00317.50
8.1.60.0030.00717.64
8.1.50.0000.00917.62
8.1.40.0050.00517.55
8.1.30.0040.00417.58
8.1.20.0030.00517.71
8.1.10.0000.00817.62
8.1.00.0030.00617.54
8.0.300.0050.00220.06
8.0.290.0070.00016.75
8.0.280.0000.00718.39
8.0.270.0000.00717.25
8.0.260.0070.00017.25
8.0.250.0030.00317.01
8.0.240.0040.00416.88
8.0.230.0000.00716.96
8.0.220.0000.00716.96
8.0.210.0030.00316.96
8.0.200.0030.00316.99
8.0.190.0000.00816.87
8.0.180.0070.00016.93
8.0.170.0000.00816.93
8.0.160.0040.00416.90
8.0.150.0040.00416.85
8.0.140.0040.00416.89
8.0.130.0030.00313.29
8.0.120.0020.00516.75
8.0.110.0050.00216.91
8.0.100.0040.00416.98
8.0.90.0040.00416.96
8.0.80.0090.01316.87
8.0.70.0040.00416.81
8.0.60.0070.00016.82
8.0.50.0050.00216.86
8.0.30.0110.01216.86
8.0.20.0130.01117.40
8.0.10.0040.00417.00
8.0.00.0100.00716.87
7.4.330.0060.00015.00
7.4.320.0000.00616.67
7.4.300.0060.00016.44
7.4.290.0050.00216.54
7.4.280.0060.00316.54
7.4.270.0030.00316.49
7.4.260.0040.00416.59
7.4.250.0050.00316.55
7.4.240.0040.00416.59
7.4.230.0000.00816.73
7.4.220.0090.01316.59
7.4.210.0120.00316.59
7.4.200.0040.00416.56
7.4.160.0000.01516.66
7.4.150.0100.01317.40
7.4.140.0080.01017.86
7.4.130.0150.00516.52
7.4.120.0100.00716.55
7.4.110.0100.00716.46
7.4.100.0080.01216.57
7.4.90.0080.01116.67
7.4.80.0070.01619.39
7.4.70.0060.01016.60
7.4.60.0060.01016.41
7.4.50.0080.00016.29
7.4.40.0160.00716.56
7.4.30.0060.01116.66
7.4.00.0060.00915.08
7.3.330.0000.00513.32
7.3.320.0020.00213.34
7.3.310.0030.00316.33
7.3.300.0040.00416.32
7.3.290.0040.01516.30
7.3.280.0110.00616.31
7.3.270.0140.01117.40
7.3.260.0190.00416.65
7.3.250.0110.00816.36
7.3.240.0140.00716.36
7.3.230.0120.00416.66
7.3.210.0040.01716.39
7.3.200.0100.00919.39
7.3.190.0100.01316.69
7.3.180.0160.00016.55
7.3.170.0110.00516.32
7.3.160.0030.01216.29
7.3.10.0080.00816.28
7.3.00.0070.01016.43
7.2.330.0060.01216.78
7.2.320.0060.01016.84
7.2.310.0080.00816.54
7.2.300.0090.00816.46
7.2.290.0100.01316.86
7.2.130.0060.00816.59
7.2.120.0090.00816.70
7.2.110.0100.00616.59
7.2.100.0090.01016.53
7.2.90.0080.01016.78
7.2.80.0100.00616.50
7.2.70.0050.01016.56
7.2.60.0130.00416.68
7.2.50.0110.00916.70
7.2.40.0120.00616.63
7.2.30.0070.01116.62
7.2.20.0130.00616.54
7.2.10.0090.01116.56
7.2.00.0070.00817.74
7.1.250.0070.01015.26
7.1.100.0060.00318.05
7.1.70.0040.00417.03
7.1.60.0130.01019.11
7.1.50.0040.01816.77
7.1.00.0000.07722.35
7.0.200.0080.00016.82
7.0.140.0030.07322.00
7.0.60.0070.08319.96
7.0.50.0070.05317.90
7.0.40.0030.05320.18
7.0.30.0430.07720.21
7.0.20.0230.09020.30
7.0.10.0070.07020.23
7.0.00.0070.04020.09
5.6.280.0070.07020.84
5.6.210.0100.03720.63
5.6.200.0030.04018.25
5.6.190.0030.05720.79
5.6.180.0270.07320.43
5.6.170.0400.06020.48
5.6.160.0070.08720.45
5.6.150.0030.04318.27
5.6.140.0070.03718.18
5.6.130.0130.08018.27
5.6.120.0170.07720.86
5.6.110.0130.06720.99
5.6.100.0070.08720.97
5.6.90.0200.06320.99
5.6.80.0070.08320.38
5.5.350.0130.03320.41
5.5.340.0000.07717.94
5.5.330.0130.03320.21
5.5.320.0300.04020.23
5.5.310.0270.08020.32
5.5.300.0070.06718.05
5.5.290.0030.05017.94
5.5.280.0100.08020.86
5.5.270.0070.04020.66
5.5.260.0130.03020.84
5.5.250.0030.07020.78
5.5.240.0230.07020.17
5.4.450.2770.03019.55
5.4.440.0000.04319.27
5.4.430.0030.04019.41
5.4.420.0830.04319.46
5.4.410.1370.03719.34
5.4.400.1800.04019.13
5.4.390.1730.03718.98
5.4.380.1770.03319.31
5.4.370.1700.04019.14
5.4.360.2330.05318.83
5.4.350.1770.03719.01
5.4.340.1870.03319.20
5.4.320.1870.03019.09
5.4.310.1730.03318.95
5.4.300.0870.04019.24
5.4.290.0030.04019.22
5.4.280.0000.04018.98
5.4.270.2230.04319.08
5.4.260.1700.03319.19
5.4.250.1570.03319.19
5.4.240.1630.03719.05
5.4.230.2100.04018.83
5.4.220.1870.04018.88
5.4.210.1530.03719.21
5.4.200.1870.03319.18
5.4.190.1830.03718.83
5.4.180.1800.03718.82
5.4.170.1070.03718.99
5.4.160.0000.04018.84
5.4.150.0030.05719.04
5.4.140.0930.04016.55
5.4.130.1700.03016.56
5.4.120.1630.03316.56
5.4.110.2030.04016.35
5.4.100.2230.03316.63
5.4.90.2070.04316.42
5.4.80.1970.04316.63
5.4.70.1800.03716.57
5.4.60.1800.03316.54
5.4.50.1970.03716.38
5.4.40.1630.03716.54
5.4.30.0030.05716.50
5.4.20.0030.07716.17
5.4.10.1130.04016.52
5.4.00.1700.03715.82
5.3.290.2000.03314.57
5.3.280.2030.03314.59
5.3.270.1770.05014.73
5.3.260.1730.04014.52
5.3.250.2000.04714.63
5.3.240.2070.03714.83
5.3.230.1970.04314.74
5.3.220.2000.04314.79
5.3.210.0000.05014.65
5.3.200.0030.04314.57
5.3.190.0830.04314.71
5.3.180.2030.04014.49
5.3.170.2070.03014.68
5.3.160.1230.04014.68
5.3.150.0070.05714.48
5.3.140.0030.04714.48
5.3.130.0000.04314.66
5.3.120.1700.03714.60
5.3.110.1930.04714.52
5.3.100.1900.03014.27
5.3.90.1800.03714.00
5.3.80.1770.03713.92
5.3.70.1830.03313.95
5.3.60.1230.03013.91
5.3.50.0030.03314.06
5.3.40.0000.04314.00
5.3.30.0000.03714.14
5.3.20.0000.03713.84
5.3.10.0130.04013.89
5.3.00.1830.03313.56
5.2.170.1530.03711.27
5.2.160.1730.03711.07
5.2.150.1530.02711.20
5.2.140.1700.03311.05
5.2.130.1830.03011.04
5.2.120.1500.03011.01
5.2.110.1570.02311.35
5.2.100.1530.02711.03
5.2.90.1530.02711.19
5.2.80.1470.03311.10
5.2.70.1100.03011.01
5.2.60.0000.03011.17
5.2.50.0030.05310.99
5.2.40.0030.02711.08
5.2.30.1300.03010.87
5.2.20.1370.03010.91
5.2.10.1170.03011.01
5.2.00.1470.03310.80
5.1.60.1430.03010.05
5.1.50.1400.02710.07
5.1.40.1170.02310.06
5.1.30.1400.03010.49
5.1.20.1330.02310.33
5.1.10.1330.03310.08
5.1.00.1330.03010.00
5.0.50.0800.0278.59
5.0.40.0570.0238.50
5.0.30.0830.0378.45
5.0.20.0770.0308.21
5.0.10.0500.0278.08
5.0.00.0000.0308.10
4.4.90.0000.0207.95
4.4.80.0070.0107.95
4.4.70.0030.0137.95
4.4.60.0030.0137.95
4.4.50.0070.0337.95
4.4.40.0030.0437.95
4.4.30.0170.0207.95
4.4.20.0730.0137.95
4.4.10.0770.0277.95
4.4.00.0670.0307.95
4.3.110.0600.0137.95
4.3.100.0800.0207.95
4.3.90.0800.0177.95
4.3.80.0730.0377.95
4.3.70.0770.0237.95
4.3.60.0630.0137.95
4.3.50.0570.0177.95
4.3.40.0670.0307.95
4.3.30.0330.0107.95
4.3.20.0430.0277.95
4.3.10.0400.0307.95
4.3.00.0400.0207.95

preferences:
45.59 ms | 401 KiB | 5 Q