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);

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.00418.43
8.3.50.0130.00622.04
8.3.40.0070.00718.71
8.3.30.0090.00619.13
8.3.20.0080.00020.09
8.3.10.0060.00323.70
8.3.00.0080.00019.38
8.2.180.0150.00016.75
8.2.170.0060.00822.96
8.2.160.0100.00720.38
8.2.150.0090.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0030.00620.53
8.2.110.0030.00620.38
8.2.100.0090.00318.22
8.2.90.0040.00419.24
8.2.80.0090.00017.97
8.2.70.0060.00317.50
8.2.60.0030.00617.93
8.2.50.0100.00018.07
8.2.40.0000.01018.22
8.2.30.0090.00018.09
8.2.20.0040.00417.59
8.2.10.0000.00718.08
8.2.00.0000.00717.75
8.1.280.0030.01425.92
8.1.270.0040.00422.14
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00323.92
8.1.230.0040.00719.16
8.1.220.0040.00417.74
8.1.210.0030.00618.77
8.1.200.0080.00017.35
8.1.190.0030.00617.23
8.1.180.0000.00818.10
8.1.170.0030.00718.64
8.1.160.0040.00422.01
8.1.150.0070.00018.92
8.1.140.0050.00217.59
8.1.130.0040.00417.90
8.1.120.0050.00317.54
8.1.110.0000.00817.53
8.1.100.0040.00417.39
8.1.90.0000.00817.52
8.1.80.0000.00717.39
8.1.70.0070.00017.48
8.1.60.0000.01017.51
8.1.50.0040.00417.54
8.1.40.0080.00017.55
8.1.30.0040.00417.74
8.1.20.0040.00417.59
8.1.10.0060.00317.64
8.1.00.0080.00017.55
8.0.300.0040.00418.77
8.0.290.0070.00016.61
8.0.280.0030.00318.42
8.0.270.0040.00417.29
8.0.260.0030.00317.21
8.0.250.0000.00716.90
8.0.240.0030.00516.88
8.0.230.0000.00716.98
8.0.220.0000.00716.84
8.0.210.0000.00816.88
8.0.200.0030.00316.97
8.0.190.0060.00316.87
8.0.180.0050.00316.95
8.0.170.0050.00316.91
8.0.160.0030.00316.82
8.0.150.0020.00516.79
8.0.140.0000.00716.94
8.0.130.0000.00613.32
8.0.120.0030.00616.89
8.0.110.0000.00716.98
8.0.100.0000.00716.79
8.0.90.0020.00516.98
8.0.80.0070.01516.95
8.0.70.0080.00016.81
8.0.60.0040.00416.83
8.0.50.0020.00516.94
8.0.30.0110.01217.10
8.0.20.0110.01117.40
8.0.10.0040.00416.91
8.0.00.0140.00416.66
7.4.330.0000.00515.00
7.4.320.0030.00316.68
7.4.300.0030.00316.55
7.4.290.0030.00316.46
7.4.280.0040.00916.45
7.4.270.0000.00916.56
7.4.260.0000.00716.47
7.4.250.0000.00816.59
7.4.240.0050.00216.57
7.4.230.0040.00416.58
7.4.220.0040.01416.45
7.4.210.0160.00316.64
7.4.200.0050.00516.70
7.4.160.0070.01416.54
7.4.150.0060.02017.40
7.4.140.0120.00517.86
7.4.130.0100.00716.52
7.4.120.0080.01016.51
7.4.110.0080.00816.34
7.4.100.0060.01316.62
7.4.90.0090.00916.48
7.4.80.0030.01519.39
7.4.70.0120.00416.33
7.4.60.0100.00716.65
7.4.50.0000.00816.54
7.4.40.0100.00616.67
7.4.30.0100.00616.37
7.4.00.0050.01114.82
7.3.330.0000.00513.14
7.3.320.0060.00013.35
7.3.310.0000.00716.36
7.3.300.0070.00016.25
7.3.290.0100.01316.34
7.3.280.0090.00716.35
7.3.270.0100.01717.40
7.3.260.0120.00616.39
7.3.250.0120.00516.34
7.3.240.0070.01116.75
7.3.230.0080.00816.54
7.3.210.0030.01316.67
7.3.200.0090.01219.39
7.3.190.0140.00716.55
7.3.180.0140.00716.63
7.3.170.0070.01016.48
7.3.160.0030.01616.66
7.3.120.0100.01014.71
7.3.110.0040.01114.54
7.3.100.0090.00614.70
7.3.90.0060.00914.80
7.3.80.0090.00614.77
7.3.70.0000.01514.79
7.3.60.0040.01114.97
7.3.50.0040.01114.82
7.3.40.0070.00714.77
7.3.30.0040.01114.85
7.3.20.0030.01416.83
7.3.10.0060.00916.77
7.3.00.0100.00716.58
7.2.330.0120.00616.52
7.2.320.0130.00916.78
7.2.310.0100.00716.59
7.2.300.0070.01016.73
7.2.290.0070.01416.72
7.2.250.0160.00315.18
7.2.240.0070.01414.80
7.2.230.0130.00315.27
7.2.220.0000.01415.18
7.2.210.0070.01015.04
7.2.200.0090.00314.75
7.2.190.0040.00815.21
7.2.180.0100.01014.93
7.2.170.0050.00515.17
7.2.60.0070.00717.06
7.2.00.0080.00819.34
7.1.330.0070.00716.01
7.1.320.0070.01015.82
7.1.310.0040.00715.84
7.1.300.0120.00315.70
7.1.290.0030.01515.80
7.1.280.0060.00915.95
7.1.270.0070.00715.52
7.1.260.0060.00915.80
7.1.200.0060.00615.85
7.1.100.0070.00317.93
7.1.70.0040.00417.09
7.1.60.0100.01319.11
7.1.50.0150.00316.80
7.1.00.0100.07022.35
7.0.200.0090.00016.95
7.0.140.0030.07722.01
7.0.60.0000.04320.00
7.0.50.0030.07717.88
7.0.40.0100.07020.20
7.0.30.0300.05020.20
7.0.20.0270.08020.10
7.0.10.0030.04320.21
7.0.00.0030.04720.16
5.6.280.0030.07321.11
5.6.210.0000.04320.52
5.6.200.0070.04018.16
5.6.190.0030.04720.47
5.6.180.0230.05720.41
5.6.170.0400.06720.45
5.6.160.0100.05020.44
5.6.150.0070.04018.13
5.6.140.0030.04318.15
5.6.130.0030.04018.20
5.6.120.0070.08720.81
5.6.110.0000.04720.97
5.6.100.0100.04321.01
5.6.90.0070.09020.96
5.6.80.0030.04020.54
5.5.350.0100.08320.40
5.5.340.0100.08317.94
5.5.330.0170.03720.44
5.5.320.0330.07720.32
5.5.310.0270.07320.28
5.5.300.0030.06317.95
5.5.290.0070.08317.94
5.5.280.0130.04320.89
5.5.270.0070.05320.88
5.5.260.0030.04320.88
5.5.250.0000.04320.61
5.5.240.0230.06720.18
5.4.450.0200.05319.59
5.4.440.0830.06719.47
5.4.430.0830.06319.60
5.4.420.0670.00019.52
5.4.410.0670.00019.30
5.4.400.0630.00019.27
5.4.390.0630.00019.06
5.4.380.0670.00019.11
5.4.370.0600.00019.11
5.4.360.0730.00019.11
5.4.350.0800.00019.07
5.4.340.0060.03912.02
5.4.320.0070.03912.52
5.4.310.0080.03912.52
5.4.300.0080.03912.52
5.4.290.0030.04212.51
5.4.280.0060.03512.41
5.4.270.0040.03812.41
5.4.260.0050.03812.41
5.4.250.0070.03612.41
5.4.240.0040.03712.41
5.4.230.0060.03812.40
5.4.220.0080.03412.40
5.4.210.0060.03512.40
5.4.200.0070.03612.40
5.4.190.0090.03412.39
5.4.180.0050.03812.40
5.4.170.0040.03912.41
5.4.160.0040.03812.41
5.4.150.0050.03612.40
5.4.140.0050.03912.09
5.4.130.0090.03512.07
5.4.120.0040.04012.03
5.4.110.0050.03812.02
5.4.100.0060.03612.03
5.4.90.0110.03212.02
5.4.80.0090.03212.03
5.4.70.0120.02912.02
5.4.60.0050.03512.02
5.4.50.0040.03712.02
5.4.40.0040.03712.01
5.4.30.0100.03212.01
5.4.20.0090.03212.01
5.4.10.0080.03412.01
5.4.00.0070.03611.50
5.3.290.0060.04012.80
5.3.280.0060.03912.71
5.3.270.0070.03912.73
5.3.260.0070.03812.72
5.3.250.0050.03812.72
5.3.240.0060.03912.72
5.3.230.0060.03912.71
5.3.220.0120.03912.68
5.3.210.0050.05612.68
5.3.200.0080.05012.68
5.3.190.0100.04712.68
5.3.180.0080.05012.68
5.3.170.0090.04912.66
5.3.160.0110.04912.67
5.3.150.0100.05012.67
5.3.140.0080.05212.66
5.3.130.0070.05112.66
5.3.120.0060.03812.66
5.3.110.0050.03912.66
5.3.100.0050.03812.13
5.3.90.0100.03312.11
5.3.80.0070.03612.10
5.3.70.0070.03512.10
5.3.60.0060.03612.09
5.3.50.0050.03712.03
5.3.40.0050.03712.03
5.3.30.0050.03611.98
5.3.20.0070.03411.77
5.3.10.0060.03411.74
5.3.00.0060.03511.72
5.2.170.0040.0319.22
5.2.160.0050.0289.22
5.2.150.0020.0339.23
5.2.140.0060.0299.22
5.2.130.0010.0329.18
5.2.120.0030.0299.18
5.2.110.0040.0309.19
5.2.100.0020.0329.18
5.2.90.0050.0299.18
5.2.80.0050.0309.18
5.2.70.0040.0319.18
5.2.60.0030.0329.14
5.2.50.0050.0309.11
5.2.40.0080.0259.08
5.2.30.0060.0299.05
5.2.20.0080.0269.04
5.2.10.0020.0308.95
5.2.00.0060.0288.82
5.1.60.0030.0278.09
5.1.50.0050.0248.09
5.1.40.0050.0268.07
5.1.30.0040.0318.42
5.1.20.0060.0258.44
5.1.10.0090.0308.17
5.1.00.0040.0298.18
5.0.50.0060.0216.64
5.0.40.0060.0226.50
5.0.30.0050.0356.31
5.0.20.0050.0176.28
5.0.10.0030.0206.26
5.0.00.0040.0306.25
4.4.90.0010.0174.78
4.4.80.0040.0194.75
4.4.70.0030.0164.75
4.4.60.0030.0154.76
4.4.50.0030.0204.77
4.4.40.0040.0244.71
4.4.30.0050.0134.76
4.4.20.0020.0164.84
4.4.10.0030.0154.85
4.4.00.0010.0274.76
4.3.110.0040.0144.66
4.3.100.0040.0134.66
4.3.90.0030.0144.64
4.3.80.0050.0224.58
4.3.70.0030.0144.63
4.3.60.0020.0154.63
4.3.50.0020.0164.63
4.3.40.0010.0254.54
4.3.30.0030.0163.29
4.3.20.0000.0183.26
4.3.10.0040.0143.22
4.3.00.0200.0177.23

preferences:
41.88 ms | 401 KiB | 5 Q