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.0110.01118.62
8.3.50.0100.01222.03
8.3.40.0140.00718.72
8.3.30.0150.00319.03
8.3.20.0070.00020.21
8.3.10.0080.00023.70
8.3.00.0040.00419.13
8.2.180.0120.00316.63
8.2.170.0040.01122.96
8.2.160.0070.01122.13
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0040.00720.44
8.2.110.0090.00020.27
8.2.100.0000.01217.72
8.2.90.0040.00419.07
8.2.80.0030.00617.97
8.2.70.0060.00317.63
8.2.60.0000.00817.90
8.2.50.0000.01018.07
8.2.40.0030.00818.16
8.2.30.0000.00818.05
8.2.20.0040.00417.76
8.2.10.0040.00417.99
8.2.00.0000.00817.77
8.1.280.0070.01125.92
8.1.270.0070.00321.89
8.1.260.0000.00726.35
8.1.250.0030.00528.09
8.1.240.0090.00023.71
8.1.230.0040.00722.16
8.1.220.0000.00917.74
8.1.210.0000.00918.77
8.1.200.0040.00417.10
8.1.190.0040.00417.48
8.1.180.0000.00818.10
8.1.170.0030.00618.67
8.1.160.0040.00421.99
8.1.150.0070.00018.93
8.1.140.0000.00717.42
8.1.130.0030.00317.86
8.1.120.0000.00717.48
8.1.110.0000.00917.45
8.1.100.0040.00417.50
8.1.90.0000.00717.37
8.1.80.0000.00817.44
8.1.70.0000.00717.46
8.1.60.0060.00617.60
8.1.50.0040.00417.47
8.1.40.0080.00017.44
8.1.30.0060.00317.71
8.1.20.0000.00817.64
8.1.10.0080.00017.51
8.1.00.0080.00017.50
8.0.300.0050.00218.77
8.0.290.0040.00416.63
8.0.280.0000.00718.39
8.0.270.0030.00317.30
8.0.260.0000.00617.20
8.0.250.0000.00717.00
8.0.240.0060.00316.96
8.0.230.0000.00716.99
8.0.220.0070.00016.91
8.0.210.0030.00316.83
8.0.200.0070.00016.98
8.0.190.0040.00417.00
8.0.180.0020.00517.00
8.0.170.0000.00917.01
8.0.160.0000.00816.98
8.0.150.0040.00416.98
8.0.140.0000.00716.92
8.0.130.0030.00313.35
8.0.120.0040.00416.90
8.0.110.0000.00716.92
8.0.100.0050.00316.80
8.0.90.0040.00416.81
8.0.80.0090.01216.91
8.0.70.0040.00416.86
8.0.60.0000.00816.79
8.0.50.0000.00716.91
8.0.30.0080.01417.30
8.0.20.0120.00717.40
8.0.10.0040.00416.99
8.0.00.0090.01116.85
7.4.330.0050.00015.14
7.4.320.0000.00716.62
7.4.300.0030.00316.58
7.4.290.0040.00416.54
7.4.280.0000.00916.54
7.4.270.0000.00716.55
7.4.260.0070.00016.61
7.4.250.0050.00216.47
7.4.240.0040.00316.62
7.4.230.0050.00216.65
7.4.220.0060.01216.52
7.4.210.0120.00316.58
7.4.200.0030.00616.71
7.4.160.0080.00816.43
7.4.150.0120.00917.40
7.4.140.0120.00817.86
7.4.130.0070.01016.54
7.4.120.0040.01316.61
7.4.110.0110.01116.67
7.4.100.0110.00616.36
7.4.90.0130.00316.52
7.4.80.0130.00319.39
7.4.70.0050.01116.46
7.4.60.0060.01016.42
7.4.50.0050.00316.57
7.4.40.0140.01016.71
7.4.30.0100.01016.44
7.4.10.0040.01215.18
7.4.00.0020.01314.95
7.3.330.0030.00313.25
7.3.320.0000.00613.14
7.3.310.0040.00316.43
7.3.300.0000.00716.33
7.3.290.0030.01316.29
7.3.280.0080.01016.32
7.3.270.0100.00917.40
7.3.260.0120.00616.72
7.3.250.0130.00416.53
7.3.240.0100.01016.33
7.3.230.0160.00316.58
7.3.210.0120.00916.30
7.3.200.0150.00619.39
7.3.190.0050.01216.45
7.3.180.0060.00916.31
7.3.170.0090.00916.62
7.3.160.0110.00616.33
7.3.130.0180.00014.83
7.3.120.0080.01115.09
7.3.110.0060.00914.98
7.3.100.0070.01014.63
7.3.90.0060.01314.83
7.3.80.0060.00314.82
7.3.70.0000.01314.89
7.3.60.0000.01414.56
7.3.50.0070.00714.86
7.3.40.0000.01314.80
7.3.30.0000.01714.83
7.3.20.0000.01316.89
7.3.10.0070.00416.67
7.3.00.0100.00716.44
7.2.330.0120.00516.66
7.2.320.0030.01316.69
7.2.310.0090.01516.70
7.2.300.0030.01416.54
7.2.290.0090.00916.79
7.2.260.0040.01515.26
7.2.250.0040.01415.21
7.2.240.0060.00915.10
7.2.230.0030.01015.25
7.2.220.0070.00715.26
7.2.210.0000.00914.78
7.2.200.0000.01415.21
7.2.190.0000.01515.17
7.2.180.0030.00615.19
7.2.170.0040.01115.14
7.2.160.0040.01114.96
7.2.150.0070.00716.82
7.2.140.0070.00716.98
7.2.130.0030.01016.89
7.2.120.0030.00717.01
7.2.110.0030.00617.04
7.2.100.0030.01316.92
7.2.90.0060.00317.04
7.2.80.0000.01516.95
7.2.70.0040.01016.92
7.2.60.0070.01017.05
7.2.50.0070.00716.87
7.2.40.0080.00416.91
7.2.30.0060.00617.03
7.2.20.0000.01216.95
7.2.10.0060.00617.07
7.2.00.0090.00618.26
7.1.330.0070.00715.91
7.1.320.0030.00915.84
7.1.310.0100.00615.89
7.1.300.0060.00615.46
7.1.290.0030.00715.78
7.1.280.0040.01215.58
7.1.270.0060.00615.51
7.1.260.0000.01115.96
7.1.250.0080.00415.83
7.1.240.0060.00315.71
7.1.230.0030.00915.79
7.1.220.0040.00715.40
7.1.210.0100.00315.86
7.1.200.0040.01015.43
7.1.190.0030.01215.79
7.1.180.0060.01215.90
7.1.170.0030.01015.75
7.1.160.0060.01215.99
7.1.150.0000.00915.57
7.1.140.0100.00315.88
7.1.130.0070.00315.76
7.1.120.0060.01115.69
7.1.110.0100.00715.50
7.1.100.0080.00416.89
7.1.90.0040.00715.64
7.1.80.0040.00715.75
7.1.70.0050.00416.42
7.1.60.0120.00717.56
7.1.50.0060.01116.35
7.1.40.0060.00315.64
7.1.30.0000.00815.74
7.1.20.0030.01015.80
7.1.10.0100.00315.48
7.1.00.0080.03819.06
7.0.330.0030.01015.45
7.0.320.0000.01715.41
7.0.310.0040.01215.55
7.0.300.0020.01315.46
7.0.290.0110.00415.44
7.0.280.0030.00715.50
7.0.270.0060.00315.14
7.0.260.0060.00315.44
7.0.250.0070.00715.41
7.0.240.0030.00615.45
7.0.230.0040.00815.52
7.0.220.0080.00415.40
7.0.210.0040.00715.34
7.0.200.0010.00716.10
7.0.190.0040.00415.45
7.0.180.0060.00315.30
7.0.170.0070.00315.50
7.0.160.0060.00915.55
7.0.150.0060.00915.44
7.0.140.0050.03918.81
7.0.130.0040.01115.53
7.0.120.0100.00715.43
7.0.110.0070.00315.55
7.0.100.0000.01215.62
7.0.90.0040.01115.31
7.0.80.0030.01015.27
7.0.70.0000.00815.51
7.0.60.0050.02217.62
7.0.50.0090.03316.81
7.0.40.0030.04516.87
7.0.30.0310.03116.92
7.0.20.0160.03716.91
7.0.10.0080.02316.88
7.0.00.0030.02516.83
5.6.400.0040.00814.09
5.6.390.0150.00014.64
5.6.380.0030.01014.47
5.6.370.0110.00314.42
5.6.360.0060.00814.60
5.6.350.0060.01014.50
5.6.340.0060.00314.28
5.6.330.0070.00714.42
5.6.320.0060.00314.38
5.6.310.0030.01014.38
5.6.300.0120.00014.66
5.6.290.0040.00414.62
5.6.280.0050.03717.64
5.6.270.0090.00614.59
5.6.260.0100.00714.72
5.6.250.0040.01114.70
5.6.240.0000.01314.23
5.6.230.0060.01214.66
5.6.220.0080.00314.72
5.6.210.0080.04017.51
5.6.200.0030.02716.32
5.6.190.0070.02517.44
5.6.180.0130.04917.43
5.6.170.0230.03717.49
5.6.160.0020.03017.49
5.6.150.0030.04716.24
5.6.140.0060.03816.39
5.6.130.0020.02616.46
5.6.120.0070.02317.66
5.6.110.0070.04717.68
5.6.100.0080.04217.74
5.6.90.0050.03317.74
5.6.80.0050.02517.40
5.6.70.0040.01114.11
5.6.60.0100.00314.56
5.6.50.0000.01314.15
5.6.40.0090.00914.22
5.6.30.0100.00714.26
5.6.20.0030.00714.41
5.6.10.0030.01014.26
5.6.00.0070.00714.40
5.5.380.0040.01114.61
5.5.370.0100.00614.39
5.5.360.0040.01114.39
5.5.350.0100.03617.39
5.5.340.0050.03616.16
5.5.330.0070.04017.37
5.5.320.0250.04017.28
5.5.310.0160.04417.40
5.5.300.0030.04615.98
5.5.290.0030.04316.06
5.5.280.0050.02617.61
5.5.270.0110.03317.69
5.5.260.0060.02417.66
5.5.250.0020.02517.43
5.5.240.0150.04217.19
5.5.230.0040.00714.49
5.5.220.0060.00314.16
5.5.210.0050.00514.11
5.5.200.0030.01314.46
5.5.190.0040.00814.34
5.5.180.0070.00714.59
5.5.170.0080.00614.16
5.5.160.0030.00714.52
5.5.150.0080.00014.33
5.5.140.0040.01114.43
5.5.130.0070.00714.51
5.5.120.0060.00614.60
5.5.110.0070.00414.31
5.5.100.0070.00414.31
5.5.90.0060.00614.20
5.5.80.0070.00714.48
5.5.70.0090.00614.34
5.5.60.0060.00914.50
5.5.50.0030.00914.37
5.5.40.0080.00514.10
5.5.30.0140.00314.09
5.5.20.0030.01414.18
5.5.10.0130.00614.49
5.5.00.0040.01414.07
5.4.450.0100.03215.76
5.4.440.0380.03215.84
5.4.430.0440.03115.84
5.4.420.0320.00515.77
5.4.410.0320.00515.62
5.4.400.0300.00515.69
5.4.390.0330.00215.59
5.4.380.0350.00215.68
5.4.370.0350.00215.67
5.4.360.0370.00315.59
5.4.350.0350.00515.64
5.4.340.0090.01912.08
5.4.330.0040.00712.13
5.4.320.0080.01912.32
5.4.310.0020.02812.32
5.4.300.0040.02512.32
5.4.290.0040.02412.32
5.4.280.0050.02112.27
5.4.270.0020.02512.27
5.4.260.0030.02412.27
5.4.250.0100.01812.27
5.4.240.0050.02212.27
5.4.230.0020.02612.26
5.4.220.0070.01912.27
5.4.210.0060.02112.26
5.4.200.0090.01912.27
5.4.190.0070.02112.26
5.4.180.0070.01912.26
5.4.170.0070.02212.27
5.4.160.0070.02112.27
5.4.150.0070.02312.26
5.4.140.0020.02912.11
5.4.130.0050.02212.10
5.4.120.0090.01812.08
5.4.110.0040.02412.08
5.4.100.0060.02212.08
5.4.90.0100.02112.08
5.4.80.0050.02512.08
5.4.70.0050.02412.07
5.4.60.0050.02412.07
5.4.50.0050.02112.07
5.4.40.0040.02512.07
5.4.30.0050.02312.06
5.4.20.0090.01912.07
5.4.10.0050.02112.07
5.4.00.0070.02211.81
5.3.290.0060.04212.80
5.3.280.0060.03912.71
5.3.270.0040.04412.73
5.3.260.0080.04412.72
5.3.250.0060.03712.72
5.3.240.0050.03812.72
5.3.230.0060.03712.70
5.3.220.0060.03612.68
5.3.210.0040.04412.68
5.3.200.0110.03112.68
5.3.190.0060.03712.68
5.3.180.0050.03712.68
5.3.170.0060.03512.67
5.3.160.0040.03812.67
5.3.150.0040.03912.67
5.3.140.0040.03812.66
5.3.130.0060.03812.66
5.3.120.0070.03812.66
5.3.110.0090.03612.66
5.3.100.0070.03612.13
5.3.90.0040.03812.11
5.3.80.0070.03512.10
5.3.70.0090.03312.10
5.3.60.0070.03812.09
5.3.50.0050.03912.03
5.3.40.0050.04012.03
5.3.30.0080.03411.99
5.3.20.0090.03311.77
5.3.10.0070.03311.73
5.3.00.0060.03611.72
5.2.170.0010.0349.22
5.2.160.0030.0319.23
5.2.150.0050.0319.22
5.2.140.0060.0299.22
5.2.130.0040.0319.18
5.2.120.0060.0329.18
5.2.110.0070.0349.19
5.2.100.0030.0329.18
5.2.90.0070.0369.18
5.2.80.0070.0409.18
5.2.70.0050.0299.18
5.2.60.0040.0309.14
5.2.50.0070.0279.10
5.2.40.0020.0319.09
5.2.30.0010.0389.05
5.2.20.0060.0279.04
5.2.10.0080.0348.95
5.2.00.0060.0328.81
5.1.60.0040.0238.10
5.1.50.0060.0278.09
5.1.40.0040.0248.07
5.1.30.0060.0248.42
5.1.20.0020.0288.45
5.1.10.0050.0258.17
5.1.00.0050.0248.17
5.0.50.0060.0186.64
5.0.40.0030.0196.50
5.0.30.0070.0276.31
5.0.20.0040.0186.28
5.0.10.0050.0186.26
5.0.00.0030.0356.25
4.4.90.0020.0164.77
4.4.80.0040.0154.76
4.4.70.0020.0164.75
4.4.60.0050.0144.76
4.4.50.0030.0154.77
4.4.40.0040.0244.71
4.4.30.0020.0164.75
4.4.20.0060.0124.84
4.4.10.0010.0174.85
4.4.00.0070.0204.76
4.3.110.0020.0164.67
4.3.100.0030.0154.66
4.3.90.0030.0154.63
4.3.80.0040.0244.58
4.3.70.0060.0204.63
4.3.60.0060.0174.62
4.3.50.0040.0194.62
4.3.40.0010.0254.54
4.3.30.0010.0243.28
4.3.20.0010.0163.26
4.3.10.0010.0223.22
4.3.00.0000.0277.20

preferences:
43.74 ms | 401 KiB | 5 Q