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 $fooBoo; protected $bar; protected function setBar($value) { $this->bar = $value; } } $foo = MyCommand::fromParams(array('foo_boo' => '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.0090.00918.31
8.3.50.0110.00821.96
8.3.40.0160.00618.90
8.3.30.0060.01219.27
8.3.20.0030.01220.16
8.3.10.0030.00523.52
8.3.00.0040.00419.26
8.2.180.0070.00716.50
8.2.170.0110.00322.96
8.2.160.0090.00920.36
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0000.00826.16
8.2.120.0030.00720.44
8.2.110.0060.00321.00
8.2.100.0000.01217.72
8.2.90.0040.00417.84
8.2.80.0040.00419.09
8.2.70.0030.00717.63
8.2.60.0080.00017.80
8.2.50.0050.00318.10
8.2.40.0000.00820.03
8.2.30.0040.00418.04
8.2.20.0030.00617.59
8.2.10.0050.00217.96
8.2.00.0040.00417.70
8.1.280.0090.01125.92
8.1.270.0030.00622.22
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0000.00922.42
8.1.230.0000.01120.93
8.1.220.0000.01017.74
8.1.210.0040.00418.95
8.1.200.0000.01017.23
8.1.190.0000.00817.35
8.1.180.0040.00418.10
8.1.170.0040.00418.65
8.1.160.0000.00722.08
8.1.150.0000.00718.91
8.1.140.0040.00417.40
8.1.130.0000.00717.84
8.1.120.0000.00717.47
8.1.110.0090.00017.45
8.1.100.0050.00217.41
8.1.90.0000.00717.48
8.1.80.0000.00717.45
8.1.70.0040.00417.45
8.1.60.0050.00617.57
8.1.50.0000.00817.44
8.1.40.0060.00317.51
8.1.30.0030.00517.59
8.1.20.0000.00917.62
8.1.10.0040.00417.48
8.1.00.0000.00717.58
8.0.300.0040.00420.03
8.0.290.0070.00016.75
8.0.280.0040.00418.47
8.0.270.0000.00717.29
8.0.260.0000.00617.25
8.0.250.0000.00816.86
8.0.240.0000.00716.96
8.0.230.0000.00816.91
8.0.220.0000.00716.83
8.0.210.0040.00416.85
8.0.200.0000.00617.02
8.0.190.0080.00017.00
8.0.180.0030.00516.89
8.0.170.0080.00016.88
8.0.160.0050.00516.99
8.0.150.0030.00516.94
8.0.140.0050.00316.88
8.0.130.0000.00613.36
8.0.120.0000.00816.92
8.0.110.0020.00516.95
8.0.100.0000.00816.79
8.0.90.0050.00316.80
8.0.80.0120.00916.87
8.0.70.0000.00716.75
8.0.60.0000.00716.82
8.0.50.0000.00716.82
8.0.30.0150.00817.03
8.0.20.0100.00917.40
8.0.10.0030.00516.96
8.0.00.0140.00316.76
7.4.330.0000.00615.20
7.4.320.0000.00616.55
7.4.300.0060.00016.52
7.4.290.0030.00516.60
7.4.280.0070.00016.62
7.4.270.0000.00716.51
7.4.260.0070.00016.63
7.4.250.0070.00016.49
7.4.240.0030.00316.56
7.4.230.0030.00516.45
7.4.220.0070.01416.48
7.4.210.0060.00916.63
7.4.200.0070.00016.66
7.4.160.0080.00816.61
7.4.150.0120.00617.40
7.4.140.0120.00717.86
7.4.130.0100.00916.57
7.4.120.0140.00616.47
7.4.110.0110.00816.69
7.4.100.0070.01016.36
7.4.90.0180.00016.56
7.4.80.0170.00019.39
7.4.70.0090.00916.47
7.4.60.0100.00616.73
7.4.50.0040.00416.27
7.4.40.0110.00716.60
7.4.30.0070.01316.58
7.4.00.0020.01114.91
7.3.330.0030.00313.15
7.3.320.0020.00213.32
7.3.310.0000.00816.35
7.3.300.0050.00216.18
7.3.290.0130.00316.24
7.3.280.0090.00616.31
7.3.270.0160.01017.40
7.3.260.0200.00316.82
7.3.250.0060.01016.45
7.3.240.0090.00916.32
7.3.230.0070.01016.70
7.3.210.0070.01016.64
7.3.200.0100.01019.39
7.3.190.0090.01216.69
7.3.180.0130.00716.39
7.3.170.0090.00916.32
7.3.160.0090.00616.29
7.3.120.0030.01314.82
7.3.110.0070.01014.98
7.3.100.0110.00714.85
7.3.90.0110.00414.82
7.3.80.0080.00414.71
7.3.70.0070.01014.86
7.3.60.0000.01714.57
7.3.50.0030.01114.67
7.3.40.0000.01114.91
7.3.30.0060.00614.82
7.3.20.0100.00316.72
7.3.10.0080.00616.51
7.3.00.0080.00316.66
7.2.330.0220.00316.86
7.2.320.0040.01816.62
7.2.310.0030.01316.69
7.2.300.0150.00616.51
7.2.290.0120.00916.49
7.2.250.0100.01015.17
7.2.240.0110.00615.22
7.2.230.0080.00614.85
7.2.220.0040.01115.04
7.2.210.0070.01114.99
7.2.200.0030.00614.91
7.2.190.0040.00715.18
7.2.180.0070.01015.17
7.2.170.0080.00415.22
7.2.160.0000.01015.11
7.2.150.0060.00917.14
7.2.140.0050.00516.91
7.2.130.0030.01216.92
7.2.120.0080.00516.88
7.2.110.0070.00416.88
7.2.100.0020.01116.86
7.2.90.0060.00516.91
7.2.80.0070.00516.85
7.2.70.0030.00716.72
7.2.60.0050.00717.04
7.2.50.0040.01016.84
7.2.40.0030.00916.75
7.2.30.0060.00416.86
7.2.20.0050.01016.88
7.2.10.0010.00916.86
7.2.00.0070.00717.02
7.1.330.0060.00915.82
7.1.320.0070.01115.65
7.1.310.0140.00415.48
7.1.300.0030.01316.02
7.1.290.0050.00516.02
7.1.280.0030.00715.71
7.1.270.0100.00315.59
7.1.260.0030.01015.69
7.1.250.0020.01015.82
7.1.240.0100.00315.79
7.1.230.0090.00615.68
7.1.220.0030.01315.74
7.1.210.0000.01415.70
7.1.200.0040.00815.73
7.1.190.0090.00315.78
7.1.180.0080.00415.95
7.1.170.0000.01515.80
7.1.160.0060.01015.61
7.1.150.0080.00415.74
7.1.140.0030.01015.84
7.1.130.0040.00415.65
7.1.120.0030.01415.57
7.1.110.0030.01415.61
7.1.100.0030.01116.97
7.1.90.0000.00815.92
7.1.80.0040.00415.86
7.1.70.0050.00716.29
7.1.60.0100.01017.27
7.1.50.0080.01116.28
7.1.40.0040.01115.57
7.1.30.0060.00915.68
7.1.20.0080.00615.73
7.1.10.0080.00415.67
7.1.00.0070.04019.11
7.0.330.0070.00715.47
7.0.320.0060.00615.49
7.0.310.0070.00415.32
7.0.300.0060.00615.49
7.0.290.0030.00515.14
7.0.280.0070.00415.61
7.0.270.0000.01215.55
7.0.260.0080.00615.41
7.0.250.0070.00715.23
7.0.240.0000.00915.34
7.0.230.0000.01215.48
7.0.220.0100.00015.44
7.0.210.0100.00715.46
7.0.200.0040.00616.11
7.0.190.0000.00815.47
7.0.180.0030.01115.41
7.0.170.0070.00715.44
7.0.160.0090.00315.27
7.0.150.0070.00715.20
7.0.140.0040.04118.75
7.0.130.0060.00315.16
7.0.120.0060.01015.28
7.0.110.0000.01415.40
7.0.100.0070.00715.11
7.0.90.0110.00315.36
7.0.80.0060.00615.43
7.0.70.0100.00015.46
7.0.60.0090.01917.65
7.0.50.0080.03216.74
7.0.40.0030.02716.98
7.0.30.0270.04716.83
7.0.20.0150.02516.82
7.0.10.0050.02516.92
7.0.00.0050.03216.73
5.6.400.0090.00914.41
5.6.390.0030.00714.75
5.6.380.0060.00614.45
5.6.370.0040.00414.63
5.6.360.0030.01014.60
5.6.350.0040.00714.29
5.6.340.0030.00614.37
5.6.330.0030.00914.41
5.6.320.0040.00814.66
5.6.310.0060.00914.28
5.6.300.0070.00714.66
5.6.290.0040.01114.68
5.6.280.0000.03017.69
5.6.270.0070.01014.66
5.6.260.0090.00914.42
5.6.250.0110.00714.55
5.6.240.0100.00714.40
5.6.230.0000.00814.56
5.6.220.0040.00814.39
5.6.210.0070.04517.59
5.6.200.0070.02216.29
5.6.190.0070.02517.63
5.6.180.0210.04217.34
5.6.170.0230.02517.38
5.6.160.0060.02517.46
5.6.150.0060.04616.24
5.6.140.0060.04616.35
5.6.130.0070.02716.33
5.6.120.0080.04317.54
5.6.110.0120.03217.80
5.6.100.0030.05017.87
5.6.90.0060.03617.64
5.6.80.0050.04017.37
5.6.70.0000.01414.57
5.6.60.0080.00614.47
5.6.50.0070.00714.46
5.6.40.0000.01714.27
5.6.30.0060.00614.08
5.6.20.0030.01014.31
5.6.10.0030.01014.22
5.6.00.0120.00314.31
5.5.380.0000.00814.00
5.5.370.0040.01114.38
5.5.360.0030.00714.46
5.5.350.0060.04417.48
5.5.340.0030.03316.09
5.5.330.0110.03817.39
5.5.320.0190.02717.41
5.5.310.0150.03117.55
5.5.300.0100.04016.13
5.5.290.0100.04216.21
5.5.280.0020.03417.69
5.5.270.0060.03117.53
5.5.260.0020.02817.73
5.5.250.0100.02217.52
5.5.240.0160.04017.29
5.5.230.0040.00414.10
5.5.220.0030.00614.44
5.5.210.0070.00714.13
5.5.200.0100.00714.30
5.5.190.0070.01014.23
5.5.180.0120.00314.53
5.5.170.0040.01114.20
5.5.160.0030.01214.06
5.5.150.0060.00614.31
5.5.140.0060.00914.12
5.5.130.0070.00714.43
5.5.120.0070.00713.98
5.5.110.0030.00713.86
5.5.100.0060.00914.48
5.5.90.0000.01614.32
5.5.80.0040.00714.45
5.5.70.0100.00314.29
5.5.60.0070.01014.14
5.5.50.0060.00914.33
5.5.40.0000.01014.48
5.5.30.0040.01414.13
5.5.20.0060.00914.49
5.5.10.0040.01214.23
5.5.00.0000.01513.80
5.4.450.0560.02615.36
5.4.440.0430.03315.16
5.4.430.0480.03115.28
5.4.420.0350.00215.19
5.4.410.0350.00315.34
5.4.400.0320.00415.08
5.4.390.0340.00315.19
5.4.380.0330.00215.20
5.4.370.0410.00115.02
5.4.360.0320.00315.12
5.4.350.0350.00314.98
5.4.340.0040.02211.52
5.4.330.0030.00711.18
5.4.320.0050.02111.80
5.4.310.0070.01911.77
5.4.300.0060.02011.75
5.4.290.0020.02411.80
5.4.280.0070.02011.87
5.4.270.0050.01911.70
5.4.260.0040.02111.77
5.4.250.0040.02011.80
5.4.240.0050.02211.82
5.4.230.0060.02011.71
5.4.220.0080.01911.83
5.4.210.0080.01611.69
5.4.200.0060.02011.78
5.4.190.0040.02211.79
5.4.180.0020.02411.69
5.4.170.0070.01811.78
5.4.160.0060.02011.69
5.4.150.0040.02211.69
5.4.140.0050.02211.68
5.4.130.0090.01611.53
5.4.120.0050.02111.71
5.4.110.0080.01711.51
5.4.100.0040.02311.57
5.4.90.0050.02211.56
5.4.80.0040.02211.63
5.4.70.0020.02111.54
5.4.60.0080.01711.54
5.4.50.0040.02211.67
5.4.40.0040.02111.53
5.4.30.0080.01811.66
5.4.20.0040.02311.57
5.4.10.0020.02411.65
5.4.00.0070.01911.25
5.3.290.0080.03812.80
5.3.280.0070.03812.71
5.3.270.0080.03712.72
5.3.260.0080.03712.72
5.3.250.0050.03812.72
5.3.240.0070.03612.72
5.3.230.0070.03712.71
5.3.220.0080.03612.68
5.3.210.0070.03912.68
5.3.200.0080.03412.68
5.3.190.0060.03812.68
5.3.180.0070.03612.67
5.3.170.0060.03712.67
5.3.160.0090.03412.68
5.3.150.0050.03812.68
5.3.140.0060.03512.66
5.3.130.0040.03912.66
5.3.120.0090.04112.65
5.3.110.0060.04112.66
5.3.100.0100.03412.13
5.3.90.0090.03412.11
5.3.80.0070.05012.10
5.3.70.0080.03512.10
5.3.60.0100.03412.08
5.3.50.0080.04312.03
5.3.40.0070.03512.03
5.3.30.0060.03411.99
5.3.20.0070.03411.77
5.3.10.0060.03411.73
5.3.00.0050.03811.72
5.2.170.0060.0289.22
5.2.160.0070.0269.23
5.2.150.0060.0329.22
5.2.140.0070.0289.22
5.2.130.0020.0309.18
5.2.120.0050.0279.18
5.2.110.0070.0329.19
5.2.100.0070.0269.18
5.2.90.0050.0299.18
5.2.80.0040.0319.18
5.2.70.0050.0309.18
5.2.60.0060.0289.14
5.2.50.0050.0299.11
5.2.40.0080.0279.08
5.2.30.0060.0289.05
5.2.20.0070.0269.04
5.2.10.0070.0278.95
5.2.00.0050.0288.81
5.1.60.0040.0248.10
5.1.50.0060.0248.09
5.1.40.0050.0248.07
5.1.30.0070.0308.42
5.1.20.0060.0238.45
5.1.10.0060.0238.17
5.1.00.0030.0258.17
5.0.50.0060.0236.64
5.0.40.0040.0186.51
5.0.30.0040.0306.31
5.0.20.0060.0166.28
5.0.10.0040.0206.26
5.0.00.0050.0296.25
4.4.90.0060.0124.78
4.4.80.0000.0174.75
4.4.70.0040.0154.76
4.4.60.0060.0204.75
4.4.50.0030.0144.77
4.4.40.0030.0314.70
4.4.30.0060.0184.76
4.4.20.0010.0214.85
4.4.10.0040.0164.85
4.4.00.0030.0244.76
4.3.110.0020.0164.67
4.3.100.0020.0154.66
4.3.90.0010.0154.63
4.3.80.0030.0234.58
4.3.70.0020.0144.63
4.3.60.0030.0144.63
4.3.50.0010.0164.62
4.3.40.0030.0234.54
4.3.30.0000.0223.28
4.3.20.0020.0263.26
4.3.10.0040.0203.22
4.3.00.0130.0237.23

preferences:
52.97 ms | 401 KiB | 5 Q