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; 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 (isset(self::$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.0140.00718.30
8.3.50.0180.00321.26
8.3.40.0100.00518.70
8.3.30.0100.01018.97
8.3.20.0050.00220.38
8.3.10.0040.00421.90
8.3.00.0040.00419.25
8.2.180.0040.01216.61
8.2.170.0040.01122.96
8.2.160.0160.00320.43
8.2.150.0110.01124.18
8.2.140.0060.00324.66
8.2.130.0070.00026.16
8.2.120.0030.00622.23
8.2.110.0030.00719.35
8.2.100.0110.00017.84
8.2.90.0050.00518.22
8.2.80.0040.00417.97
8.2.70.0060.00617.38
8.2.60.0030.00618.04
8.2.50.0000.00818.07
8.2.40.0000.00818.08
8.2.30.0060.00318.08
8.2.20.0050.00317.60
8.2.10.0040.00418.01
8.2.00.0000.00817.66
8.1.280.0140.00325.92
8.1.270.0080.00022.01
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0090.00019.27
8.1.230.0060.00620.92
8.1.220.0040.00417.78
8.1.210.0000.00819.00
8.1.200.0030.00617.35
8.1.190.0060.00317.38
8.1.180.0000.00718.10
8.1.170.0030.00518.46
8.1.160.0000.00821.96
8.1.150.0040.00418.97
8.1.140.0040.00417.45
8.1.130.0080.00017.77
8.1.120.0000.00817.51
8.1.110.0040.00417.34
8.1.100.0000.00717.52
8.1.90.0000.00817.53
8.1.80.0040.00417.52
8.1.70.0000.00817.44
8.1.60.0060.00617.62
8.1.50.0040.00417.47
8.1.40.0000.00917.52
8.1.30.0080.00017.60
8.1.20.0030.00517.75
8.1.10.0040.00417.62
8.1.00.0000.00817.59
8.0.300.0040.00419.93
8.0.290.0070.00016.63
8.0.280.0030.00318.48
8.0.270.0030.00317.32
8.0.260.0030.00317.25
8.0.250.0030.00517.01
8.0.240.0040.00417.00
8.0.230.0050.00217.00
8.0.220.0070.00016.92
8.0.210.0050.00216.89
8.0.200.0040.00417.00
8.0.190.0000.00916.86
8.0.180.0000.00816.87
8.0.170.0060.00316.92
8.0.160.0040.00416.87
8.0.150.0030.00316.80
8.0.140.0000.00816.84
8.0.130.0050.00013.28
8.0.120.0000.00816.85
8.0.110.0050.00516.84
8.0.100.0000.00816.93
8.0.90.0040.00416.77
8.0.80.0120.01016.81
8.0.70.0040.00416.96
8.0.60.0050.00216.92
8.0.50.0040.00416.95
8.0.30.0130.00717.28
8.0.20.0160.00817.40
8.0.10.0000.00716.93
8.0.00.0050.01216.79
7.4.330.0000.00515.00
7.4.320.0000.00716.67
7.4.300.0060.00016.52
7.4.290.0000.00716.55
7.4.280.0000.01216.57
7.4.270.0030.00316.55
7.4.260.0000.00816.45
7.4.250.0000.00716.50
7.4.240.0040.00316.64
7.4.230.0070.00016.59
7.4.220.0090.00916.48
7.4.210.0060.00916.64
7.4.200.0040.00416.61
7.4.160.0130.00316.77
7.4.150.0090.00917.40
7.4.140.0160.00217.86
7.4.130.0090.01016.57
7.4.120.0100.01016.59
7.4.110.0060.01116.45
7.4.100.0100.00716.55
7.4.90.0120.00916.60
7.4.80.0060.01519.39
7.4.70.0100.00816.62
7.4.60.0000.01716.47
7.4.50.0000.00716.45
7.4.40.0100.00716.62
7.4.30.0070.01416.59
7.4.00.0040.01114.78
7.3.330.0000.00513.33
7.3.320.0060.00013.17
7.3.310.0000.00816.34
7.3.300.0030.00316.19
7.3.290.0070.00716.30
7.3.280.0040.01116.29
7.3.270.0090.00917.40
7.3.260.0160.00316.41
7.3.250.0080.00816.49
7.3.240.0100.01816.66
7.3.230.0060.01016.39
7.3.210.0070.01016.38
7.3.200.0090.00919.39
7.3.190.0110.00716.35
7.3.180.0120.00416.62
7.3.170.0170.00316.52
7.3.160.0130.00316.40
7.2.330.0130.00516.86
7.2.320.0120.00916.95
7.2.310.0070.01016.82
7.2.300.0100.00716.44
7.2.290.0130.00616.80
7.2.60.0060.01016.78
7.2.00.0030.01019.49
7.1.200.0040.00815.89
7.1.100.0080.00617.94
7.1.70.0000.01017.16
7.1.60.0110.01419.32
7.1.50.0070.01416.61
7.1.00.0070.07322.47
7.0.200.0040.00416.61
7.0.140.0030.07322.00
7.0.60.0100.04020.00
7.0.50.0070.08018.01
7.0.40.0070.08320.40
7.0.30.0470.06720.08
7.0.20.0230.05720.15
7.0.10.0030.05720.06
7.0.00.0100.03720.05
5.6.210.0000.04720.62
5.6.200.0070.04318.25
5.6.190.0070.09020.33
5.6.180.0270.07320.67
5.6.170.0200.05020.54
5.6.160.0030.05720.48
5.6.150.0100.08018.18
5.6.140.0070.03718.24
5.6.130.0000.08318.28
5.6.120.0000.09320.75
5.6.110.0200.05721.09
5.6.100.0100.05321.04
5.6.90.0030.08321.01
5.6.80.0070.07320.48
5.5.350.0200.04020.43
5.5.340.0030.08718.04
5.5.330.0030.04320.29
5.5.320.0270.04720.31
5.5.310.0370.06320.51
5.5.300.0130.05017.98
5.5.290.0070.04717.96
5.5.280.0070.06720.79
5.5.270.0130.08020.62
5.5.260.0030.04020.97
5.5.250.0100.07720.70
5.5.240.0170.08020.28
5.4.450.0830.05319.61
5.4.440.0730.05719.61
5.4.430.0870.06319.45
5.4.420.0630.00019.63
5.4.410.0670.00019.42
5.4.400.0800.00019.33
5.4.390.0630.00019.08
5.4.380.0630.00019.09
5.4.370.0600.00019.11
5.4.360.0730.00019.07
5.4.350.0670.00019.16
5.4.340.0150.05212.03
5.4.320.0050.04112.51
5.4.310.0050.04012.52
5.4.300.0060.03812.52
5.4.290.0070.03712.51
5.4.280.0090.03912.41
5.4.270.0120.04112.41
5.4.260.0050.05312.41
5.4.250.0040.04912.41
5.4.240.0120.04012.41
5.4.230.0050.07012.40
5.4.220.0030.03912.40
5.4.210.0060.03712.40
5.4.200.0080.03712.40
5.4.190.0060.03712.40
5.4.180.0080.03512.40
5.4.170.0070.03612.41
5.4.160.0110.06912.41
5.4.150.0070.04112.40
5.4.140.0090.05212.09
5.4.130.0110.03212.07
5.4.120.0120.04712.03
5.4.110.0060.03912.03
5.4.100.0090.03712.03
5.4.90.0110.03912.03
5.4.80.0070.05612.03
5.4.70.0080.04012.02
5.4.60.0050.04012.02
5.4.50.0080.03712.02
5.4.40.0080.03312.01
5.4.30.0090.03412.01
5.4.20.0050.04112.01
5.4.10.0090.03812.01
5.4.00.0090.04311.50
5.3.290.0140.03812.80
5.3.280.0100.05512.70
5.3.270.0060.04112.72
5.3.260.0060.05612.72
5.3.250.0100.04912.72
5.3.240.0090.04112.72
5.3.230.0050.04212.71
5.3.220.0100.06212.68
5.3.210.0140.03312.68
5.3.200.0060.03712.68
5.3.190.0070.03612.68
5.3.180.0090.03412.67
5.3.170.0080.03612.66
5.3.160.0080.04712.67
5.3.150.0080.05312.67
5.3.140.0080.04512.66
5.3.130.0070.03912.66
5.3.120.0050.04112.66
5.3.110.0040.04112.66
5.3.100.0060.03712.12
5.3.90.0060.03712.11
5.3.80.0070.04012.09
5.3.70.0040.03812.10
5.3.60.0040.03912.08
5.3.50.0060.04612.03
5.3.40.0130.07012.03
5.3.30.0120.05311.99
5.3.20.0080.03811.77
5.3.10.0080.05011.73
5.3.00.0110.05111.72
5.2.170.0070.0449.22
5.2.160.0070.0429.22
5.2.150.0070.0369.22
5.2.140.0070.0339.22
5.2.130.0040.0329.18
5.2.120.0110.0479.18
5.2.110.0080.0289.19
5.2.100.0070.0279.18
5.2.90.0060.0369.18
5.2.80.0070.0399.18
5.2.70.0090.0289.18
5.2.60.0060.0349.14
5.2.50.0050.0429.11
5.2.40.0090.0369.08
5.2.30.0030.0379.05
5.2.20.0030.0359.04
5.2.10.0050.0298.95
5.2.00.0050.0318.81
5.1.60.0060.0338.10
5.1.50.0070.0348.09
5.1.40.0040.0358.07
5.1.30.0100.0258.42
5.1.20.0070.0258.44
5.1.10.0040.0348.17
5.1.00.0040.0298.18
5.0.50.0030.0236.64
5.0.40.0010.0286.50
5.0.30.0020.0346.31
5.0.20.0020.0236.28
5.0.10.0020.0306.26
5.0.00.0050.0396.25
4.4.90.0040.0224.77
4.4.80.0040.0174.75
4.4.70.0030.0204.76
4.4.60.0030.0184.75
4.4.50.0050.0234.77
4.4.40.0030.0254.71
4.4.30.0050.0144.76
4.4.20.0030.0164.84
4.4.10.0040.0154.85
4.4.00.0030.0264.76
4.3.110.0030.0164.67
4.3.100.0040.0144.66
4.3.90.0010.0174.63
4.3.80.0020.0284.58
4.3.70.0020.0164.63
4.3.60.0030.0154.63
4.3.50.0010.0174.63
4.3.40.0030.0254.54
4.3.30.0020.0243.28
4.3.20.0020.0193.26
4.3.10.0040.0153.22
4.3.00.0130.0237.21

preferences:
49.33 ms | 401 KiB | 5 Q