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 __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; public function asArray() { return get_object_vars($this); } } 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->asArray());

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.0070.01018.55
8.3.50.0100.01122.06
8.3.40.0150.00618.71
8.3.30.0060.01219.04
8.3.20.0120.00320.16
8.3.10.0030.00623.77
8.3.00.0000.00819.25
8.2.180.0090.00916.88
8.2.170.0040.01122.96
8.2.160.0100.00720.35
8.2.150.0050.00324.18
8.2.140.0030.00624.66
8.2.130.0000.00726.16
8.2.120.0070.00320.68
8.2.110.0030.00622.25
8.2.100.0090.00317.72
8.2.90.0040.00417.63
8.2.80.0060.00317.97
8.2.70.0000.00817.89
8.2.60.0060.00318.16
8.2.50.0080.00018.10
8.2.40.0040.00418.09
8.2.30.0040.00418.14
8.2.20.0000.00717.70
8.2.10.0050.00318.13
8.2.00.0000.00717.58
8.1.280.0110.00425.92
8.1.270.0040.00422.11
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0090.00022.42
8.1.230.0070.00421.02
8.1.220.0060.00317.79
8.1.210.0040.00420.86
8.1.200.0040.00717.35
8.1.190.0080.00017.35
8.1.180.0000.00918.10
8.1.170.0000.00818.66
8.1.160.0000.00722.05
8.1.150.0000.00718.92
8.1.140.0070.00017.48
8.1.130.0030.00317.86
8.1.120.0040.00417.57
8.1.110.0030.00617.49
8.1.100.0000.00717.49
8.1.90.0070.00017.45
8.1.80.0000.00717.51
8.1.70.0070.00017.49
8.1.60.0050.00617.66
8.1.50.0040.00417.46
8.1.40.0050.00517.44
8.1.30.0000.00917.61
8.1.20.0030.00617.66
8.1.10.0040.00417.59
8.1.00.0030.00517.53
8.0.300.0030.00620.03
8.0.290.0040.00416.75
8.0.280.0000.00718.48
8.0.270.0040.00417.29
8.0.260.0030.00317.28
8.0.250.0030.00317.00
8.0.240.0000.00716.91
8.0.230.0040.00416.85
8.0.220.0030.00316.83
8.0.210.0040.00416.92
8.0.200.0000.00616.99
8.0.190.0040.00417.03
8.0.180.0040.00416.83
8.0.170.0060.00316.87
8.0.160.0000.00816.96
8.0.150.0000.00816.96
8.0.140.0050.00316.89
8.0.130.0030.00313.39
8.0.120.0030.00516.86
8.0.110.0070.00016.81
8.0.100.0030.00517.02
8.0.90.0020.00516.82
8.0.80.0030.01316.87
8.0.70.0030.00516.98
8.0.60.0040.00417.04
8.0.50.0040.00416.73
8.0.30.0100.01217.09
8.0.20.0090.00917.40
8.0.10.0030.00617.11
8.0.00.0070.01116.91
7.4.330.0050.00015.07
7.4.320.0060.00016.55
7.4.300.0030.00316.54
7.4.290.0040.00416.49
7.4.280.0060.00316.44
7.4.270.0030.00316.47
7.4.260.0040.00416.45
7.4.250.0040.00416.64
7.4.240.0000.00716.50
7.4.230.0000.00716.45
7.4.220.0120.01216.73
7.4.210.0060.01016.74
7.4.200.0040.00416.54
7.4.160.0080.00816.51
7.4.150.0130.00617.40
7.4.140.0120.00617.86
7.4.130.0130.00516.50
7.4.120.0100.00616.57
7.4.110.0080.01016.41
7.4.100.0030.01416.47
7.4.90.0070.01016.46
7.4.80.0160.00319.39
7.4.70.0050.01416.61
7.4.60.0090.00816.36
7.4.50.0000.00816.50
7.4.40.0030.01416.49
7.4.30.0070.01016.73
7.4.00.0090.00715.04
7.3.330.0000.00613.29
7.3.320.0030.00313.09
7.3.310.0000.00716.23
7.3.300.0040.00416.18
7.3.290.0030.01316.30
7.3.280.0080.01016.36
7.3.270.0130.00317.40
7.3.260.0070.01316.25
7.3.250.0080.00916.61
7.3.240.0140.00416.27
7.3.230.0080.00816.39
7.3.210.0110.00816.38
7.3.200.0110.00719.39
7.3.190.0030.01316.43
7.3.180.0030.01316.38
7.3.170.0130.00916.33
7.3.160.0110.00516.26
7.3.120.0070.00714.65
7.3.110.0100.00814.86
7.3.100.0020.01314.86
7.3.90.0060.00914.99
7.3.80.0090.00714.79
7.3.70.0050.00714.90
7.3.60.0050.00714.86
7.3.50.0050.00814.80
7.3.40.0030.01014.66
7.3.30.0030.01014.74
7.3.20.0030.01216.51
7.3.10.0080.01116.65
7.3.00.0090.00916.59
7.2.330.0120.00616.46
7.2.320.0100.01316.61
7.2.310.0080.00816.69
7.2.300.0060.01116.67
7.2.290.0120.00916.44
7.2.250.0110.00615.07
7.2.240.0030.01514.92
7.2.230.0030.01315.24
7.2.220.0090.00615.04
7.2.210.0070.00614.85
7.2.200.0050.00915.17
7.2.190.0060.00615.02
7.2.180.0070.00915.16
7.2.170.0040.00815.13
7.2.130.0270.00316.96
7.2.120.0160.01216.54
7.2.110.0180.01116.92
7.2.100.0160.01216.40
7.2.90.0070.01316.66
7.2.80.0140.01416.82
7.2.70.0130.00616.95
7.2.60.0120.01216.84
7.2.50.0110.01116.76
7.2.40.0100.00616.72
7.2.30.0080.00817.01
7.2.20.0080.00616.75
7.2.10.0090.00616.86
7.2.00.0080.00718.21
7.1.330.0040.01115.64
7.1.320.0050.00815.88
7.1.310.0050.00815.82
7.1.300.0090.00515.82
7.1.290.0030.00815.70
7.1.280.0060.00615.57
7.1.270.0090.00415.56
7.1.260.0100.00515.66
7.1.250.0130.01015.24
7.1.200.0100.00515.07
7.1.100.0080.00618.01
7.1.70.0070.00017.07
7.1.60.0140.01019.11
7.1.50.0040.00716.86
7.1.00.0100.07022.51
7.0.200.0000.00816.82
7.0.140.0000.07722.07
7.0.60.0330.06721.75
7.0.50.0070.04717.73
7.0.40.0130.03720.11
7.0.30.0370.07320.18
7.0.20.0230.04320.10
7.0.10.0230.07720.15
7.0.00.0030.04320.22
5.6.280.0030.07320.84
5.6.210.0130.07320.62
5.6.200.0130.08018.25
5.6.190.0100.08720.48
5.6.180.0270.05020.39
5.6.170.0230.08020.41
5.6.160.0070.07720.61
5.6.150.0100.05718.25
5.6.140.0030.06718.23
5.6.130.0070.04718.13
5.6.120.0000.05021.05
5.6.110.0070.08321.11
5.6.100.0130.08021.14
5.6.90.0170.07321.04
5.6.80.0200.07020.52
5.5.350.0200.06020.41
5.5.340.0170.04717.95
5.5.330.0100.08320.13
5.5.320.0570.04020.51
5.5.310.0300.06020.30
5.5.300.0000.04018.01
5.5.290.0100.07017.95
5.5.280.0170.07020.96
5.5.270.0000.05020.78
5.5.260.0130.07720.81
5.5.250.0070.08320.72
5.5.240.0100.07320.10
5.4.450.4370.04719.32
5.4.440.2800.04319.46
5.4.430.4230.05019.59
5.4.420.3970.04019.31
5.4.410.3630.04319.42
5.4.400.3770.03319.27
5.4.390.3830.03319.11
5.4.380.3970.04019.17
5.4.370.3770.03719.22
5.4.360.3730.03019.20
5.4.350.4330.03719.26
5.4.340.3970.03319.22
5.4.320.3970.04019.11
5.4.310.3730.03318.93
5.4.300.4100.03318.97
5.4.290.3470.04019.19
5.4.280.3670.03719.14
5.4.270.3970.03718.96
5.4.260.4700.03019.24
5.4.250.4030.04319.22
5.4.240.3600.04019.19
5.4.230.4300.03719.26
5.4.220.3970.04019.04
5.4.210.3970.03718.93
5.4.200.4100.04019.19
5.4.190.0070.04019.21
5.4.180.3800.03318.92
5.4.170.3600.04019.09
5.4.160.3930.03719.08
5.4.150.2670.04018.91
5.4.140.2930.04016.41
5.4.130.3000.02016.55
5.4.120.2830.03316.50
5.4.110.3200.03316.30
5.4.100.3670.04016.41
5.4.90.4030.02316.49
5.4.80.3900.03016.52
5.4.70.3830.03716.51
5.4.60.3970.03016.54
5.4.50.3830.03016.23
5.4.40.4300.03716.49
5.4.30.4430.03716.49
5.4.20.3700.03716.51
5.4.10.3900.03016.50
5.4.00.4170.03715.87
5.3.290.3800.04014.83
5.3.280.3970.03314.52
5.3.270.3230.04014.68
5.3.260.3870.03714.64
5.3.250.3500.03714.77
5.3.240.3600.02314.63
5.3.230.3430.04014.74
5.3.220.3270.04014.62
5.3.210.3430.03714.59
5.3.200.3730.04314.58
5.3.190.3500.03314.60
5.3.180.3770.03314.58
5.3.170.3900.03714.58
5.3.160.3930.04014.57
5.3.150.3630.04314.59
5.3.140.3870.03314.56
5.3.130.3900.04314.58
5.3.120.3930.04014.55
5.3.110.3670.04014.47
5.3.100.3800.03714.11
5.3.90.4070.03014.03
5.3.80.4270.03014.08
5.3.70.3670.03714.08
5.3.60.3900.03714.03
5.3.50.4470.03714.02
5.3.40.3630.04013.87
5.3.30.4100.03313.94
5.3.20.3700.03313.68
5.3.10.3930.03013.62
5.3.00.3900.03313.66
5.2.170.3600.03011.14
5.2.160.3230.02711.30
5.2.150.3130.03011.31
5.2.140.3500.03011.32
5.2.130.3100.02711.10
5.2.120.3370.02711.14
5.2.110.3400.02711.07
5.2.100.3130.02011.18
5.2.90.3070.03011.25
5.2.80.3030.02711.25
5.2.70.3100.03311.18
5.2.60.3570.03311.07
5.2.50.3600.02711.01
5.2.40.2770.02011.00
5.2.30.2730.02711.02
5.2.20.2200.03011.02
5.2.10.2470.02310.92
5.2.00.2600.02710.75
5.1.60.2470.02710.00
5.1.50.3130.03010.00
5.1.40.3100.02010.00
5.1.30.2970.02010.39
5.1.20.2930.02010.41
5.1.10.2800.0339.98
5.1.00.2630.03310.14
5.0.50.1270.0178.55
5.0.40.1270.0238.46
5.0.30.1300.0308.36
5.0.20.1330.0178.25
5.0.10.1470.0238.24
5.0.00.1270.0308.18
4.4.90.1400.0205.95
4.4.80.1470.0135.95
4.4.70.1370.0175.95
4.4.60.1530.0105.95
4.4.50.1200.0175.95
4.4.40.1600.0205.95
4.4.30.1470.0175.95
4.4.20.1630.0175.95
4.4.10.1470.0175.95
4.4.00.1430.0275.95
4.3.110.1570.0135.95
4.3.100.1400.0105.95
4.3.90.1300.0075.95
4.3.80.1170.0275.95
4.3.70.1500.0175.95
4.3.60.1570.0175.95
4.3.50.1230.0205.95
4.3.40.1230.0235.95
4.3.30.0730.0105.95
4.3.20.0800.0235.95
4.3.10.0830.0275.95
4.3.00.0800.0205.95

preferences:
51.63 ms | 401 KiB | 5 Q