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 asArray() { return get_object_vars($this); } 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; } final class MyCommand extends Command implements DataTransferObject { protected $foo; protected $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.40.0140.00418.73
8.3.30.0070.01418.89
8.3.20.0040.00420.29
8.3.10.0080.00023.64
8.3.00.0050.00319.38
8.2.170.0090.00622.96
8.2.160.0070.00719.07
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0030.00720.55
8.2.110.0040.00419.33
8.2.100.0100.00017.84
8.2.90.0060.00319.08
8.2.80.0080.00017.97
8.2.70.0040.00417.50
8.2.60.0080.00017.68
8.2.50.0060.00318.07
8.2.40.0080.00318.03
8.2.30.0040.00417.96
8.2.20.0050.00217.63
8.2.10.0050.00317.99
8.2.00.0000.00817.63
8.1.270.0040.00422.17
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0100.00720.99
8.1.230.0060.00617.52
8.1.220.0080.00017.74
8.1.210.0040.00418.77
8.1.200.0060.00317.25
8.1.190.0030.00617.22
8.1.180.0000.00718.10
8.1.170.0080.00018.71
8.1.160.0000.00822.04
8.1.150.0050.00218.88
8.1.140.0040.00417.36
8.1.130.0030.00317.84
8.1.120.0000.00717.52
8.1.110.0050.00317.54
8.1.100.0000.00717.49
8.1.90.0000.00717.54
8.1.80.0040.00417.38
8.1.70.0000.00717.43
8.1.60.0050.00517.51
8.1.50.0000.00817.54
8.1.40.0040.00417.45
8.1.30.0040.00417.78
8.1.20.0060.00317.68
8.1.10.0070.00017.60
8.1.00.0040.00417.55
8.0.300.0040.00418.77
8.0.290.0060.00316.63
8.0.280.0040.00418.48
8.0.270.0000.00717.24
8.0.260.0040.00417.18
8.0.250.0030.00316.92
8.0.240.0000.00716.88
8.0.230.0000.00816.95
8.0.220.0000.00816.97
8.0.210.0080.00016.81
8.0.200.0030.00316.98
8.0.190.0030.00516.96
8.0.180.0070.00016.94
8.0.170.0030.00516.97
8.0.160.0040.00416.94
8.0.150.0030.00316.84
8.0.140.0000.00816.82
8.0.130.0030.00313.36
8.0.120.0040.00416.79
8.0.110.0000.00716.93
8.0.100.0080.00016.80
8.0.90.0000.00716.88
8.0.80.0060.01516.82
8.0.70.0000.00817.04
8.0.60.0000.00816.74
8.0.50.0080.00016.71
8.0.30.0120.00917.27
8.0.20.0080.01417.40
8.0.10.0060.00317.11
8.0.00.0090.00816.82
7.4.330.0000.00615.00
7.4.320.0040.00416.66
7.4.300.0030.00316.43
7.4.290.0050.00316.71
7.4.280.0060.00316.54
7.4.270.0030.00316.52
7.4.260.0000.00816.53
7.4.250.0050.00216.60
7.4.240.0030.00316.57
7.4.230.0070.00016.37
7.4.220.0050.01516.66
7.4.210.0040.01116.70
7.4.200.0060.00316.42
7.4.160.0040.01216.48
7.4.150.0180.00917.40
7.4.140.0160.00517.86
7.4.130.0080.01016.42
7.4.120.0120.00516.64
7.4.110.0110.01416.48
7.4.100.0060.01816.51
7.4.90.0140.00316.47
7.4.80.0090.00919.39
7.4.70.0130.00316.62
7.4.60.0130.00316.64
7.4.50.0000.00816.64
7.4.40.0100.00616.43
7.4.30.0060.01016.65
7.4.10.0090.00915.07
7.4.00.0060.01114.87
7.3.330.0050.00013.28
7.3.320.0020.00213.25
7.3.310.0000.00716.41
7.3.300.0000.00716.31
7.3.290.0070.00716.31
7.3.280.0060.01016.33
7.3.270.0190.00617.40
7.3.260.0080.01216.20
7.3.250.0090.00816.51
7.3.240.0150.00416.35
7.3.230.0130.00416.65
7.3.210.0100.00716.31
7.3.200.0090.00919.39
7.3.190.0030.01516.50
7.3.180.0060.00916.48
7.3.170.0070.01016.44
7.3.160.0080.00816.55
7.3.130.0160.00314.52
7.3.120.0080.01014.73
7.3.110.0080.00714.89
7.3.100.0080.00714.95
7.3.90.0080.00614.78
7.3.80.0070.00714.95
7.3.70.0060.00514.85
7.3.60.0060.00714.92
7.3.50.0050.00714.92
7.3.40.0090.00414.88
7.3.30.0060.00614.88
7.3.20.0060.00816.62
7.3.10.0030.01116.56
7.3.00.0070.00816.67
7.2.330.0140.00316.80
7.2.320.0070.01016.52
7.2.310.0070.01116.52
7.2.300.0120.00616.64
7.2.290.0060.01116.79
7.2.260.0110.00715.13
7.2.250.0060.00815.24
7.2.240.0040.01215.12
7.2.230.0100.00615.00
7.2.220.0070.00614.87
7.2.210.0070.00815.01
7.2.200.0060.00715.10
7.2.190.0050.00615.11
7.2.180.0050.00815.21
7.2.170.0080.00815.05
7.2.160.0050.00815.07
7.2.150.0060.00817.01
7.2.140.0130.00216.73
7.2.130.0070.00716.92
7.2.120.0080.00516.88
7.2.110.0050.00716.95
7.2.100.0070.00517.00
7.2.90.0050.01117.08
7.2.80.0110.00517.04
7.2.70.0040.00817.08
7.2.60.0100.00316.78
7.2.50.0020.01116.82
7.2.40.0050.01117.01
7.2.30.0090.00516.88
7.2.20.0050.00916.90
7.2.10.0050.01017.07
7.2.00.0030.01017.89
7.1.330.0070.00515.52
7.1.320.0050.00915.76
7.1.310.0070.00615.75
7.1.300.0010.01115.77
7.1.290.0060.00615.70
7.1.280.0060.00415.67
7.1.270.0040.00515.81
7.1.260.0030.01015.73
7.1.250.0020.00915.63
7.1.240.0090.00615.82
7.1.230.0090.00615.89
7.1.220.0000.01415.75
7.1.210.0080.00615.52
7.1.200.0130.00015.76
7.1.190.0070.00415.84
7.1.180.0160.00015.86
7.1.170.0030.01015.50
7.1.160.0000.01515.89
7.1.150.0030.01015.80
7.1.140.0040.00415.91
7.1.130.0030.01415.85
7.1.120.0130.00315.83
7.1.110.0130.00015.66
7.1.100.0060.00816.95
7.1.90.0060.00915.74
7.1.80.0030.00915.85
7.1.70.0020.00816.47
7.1.60.0100.01017.36
7.1.50.0100.00416.30
7.1.40.0060.00615.71
7.1.30.0070.00715.80
7.1.20.0030.01015.91
7.1.10.0040.01115.73
7.1.00.0040.03718.96
7.0.330.0100.00315.37
7.0.320.0070.00715.32
7.0.310.0060.00615.52
7.0.300.0090.00315.31
7.0.290.0000.01615.39
7.0.280.0030.01015.26
7.0.270.0030.01315.40
7.0.260.0040.00715.37
7.0.250.0030.00915.38
7.0.240.0060.00915.31
7.0.230.0030.00615.63
7.0.220.0000.01015.37
7.0.210.0090.00615.54
7.0.200.0030.00716.22
7.0.190.0040.00415.42
7.0.180.0040.00515.55
7.0.170.0070.00715.49
7.0.160.0000.00915.63
7.0.150.0030.00915.52
7.0.140.0070.03518.71
7.0.130.0090.00315.25
7.0.120.0060.00615.27
7.0.110.0070.01015.23
7.0.100.0070.00715.52
7.0.90.0000.01315.39
7.0.80.0070.00415.64
7.0.70.0060.00315.56
7.0.60.0040.02617.58
7.0.50.0040.02916.79
7.0.40.0050.04816.94
7.0.30.0310.03416.92
7.0.20.0180.04516.92
7.0.10.0050.03016.80
7.0.00.0020.02916.92
5.6.400.0030.00614.61
5.6.390.0000.01514.67
5.6.380.0000.01214.63
5.6.370.0070.00714.64
5.6.360.0080.00314.36
5.6.350.0030.01014.63
5.6.340.0090.00914.59
5.6.330.0030.01214.34
5.6.320.0130.00014.25
5.6.310.0030.01014.14
5.6.300.0030.01014.34
5.6.290.0030.00614.32
5.6.280.0020.04417.70
5.6.270.0030.01214.27
5.6.260.0100.00714.39
5.6.250.0030.01014.39
5.6.240.0000.01414.29
5.6.230.0110.00314.63
5.6.220.0030.00614.28
5.6.210.0040.03917.40
5.6.200.0030.02816.22
5.6.190.0090.04317.46
5.6.180.0100.03917.37
5.6.170.0200.03217.43
5.6.160.0090.02817.26
5.6.150.0020.02616.20
5.6.140.0080.04216.34
5.6.130.0070.02416.43
5.6.120.0040.04917.57
5.6.110.0100.03717.70
5.6.100.0120.04017.71
5.6.90.0050.03517.88
5.6.80.0020.02417.39
5.6.70.0030.01014.15
5.6.60.0000.00914.41
5.6.50.0070.00714.34
5.6.40.0110.00013.98
5.6.30.0060.00614.30
5.6.20.0030.01014.36
5.6.10.0030.01014.23
5.6.00.0110.00614.36
5.5.380.0000.01314.20
5.5.370.0030.01014.23
5.5.360.0070.00714.17
5.5.350.0140.04017.29
5.5.340.0070.02216.35
5.5.330.0080.04117.06
5.5.320.0170.03517.39
5.5.310.0150.03417.19
5.5.300.0150.03316.23
5.5.290.0120.03716.09
5.5.280.0100.04517.58
5.5.270.0130.04217.54
5.5.260.0000.03117.69
5.5.250.0070.02117.46
5.5.240.0080.04817.27
5.5.230.0060.00614.40
5.5.220.0100.00314.04
5.5.210.0090.00614.16
5.5.200.0100.00314.29
5.5.190.0030.01014.30
5.5.180.0000.01414.13
5.5.170.0030.01014.07
5.5.160.0000.01514.29
5.5.150.0030.00714.10
5.5.140.0030.00814.43
5.5.130.0030.00914.21
5.5.120.0070.01014.32
5.5.110.0060.00914.49
5.5.100.0040.00814.31
5.5.90.0030.01013.98
5.5.80.0080.00614.43
5.5.70.0000.00914.21
5.5.60.0060.00913.84
5.5.50.0030.00914.11
5.5.40.0060.00914.26
5.5.30.0030.00614.30
5.5.20.0040.01114.35
5.5.10.0110.00414.35
5.5.00.0040.00814.31
5.4.450.0150.03815.23
5.4.440.0270.03215.31
5.4.430.0350.02715.20
5.4.420.0350.00315.39
5.4.410.0320.00315.32
5.4.400.0360.00114.92
5.4.390.0320.00315.01
5.4.380.0350.00215.14
5.4.370.0330.00415.13
5.4.360.0320.00515.14
5.4.350.0360.00314.94
5.4.340.0020.02511.58
5.4.330.0040.00710.88
5.4.320.0030.02611.76
5.4.310.0060.02311.62
5.4.300.0040.02011.92
5.4.290.0050.02111.84
5.4.280.0040.02011.88
5.4.270.0050.01911.70
5.4.260.0050.02411.62
5.4.250.0040.02211.56
5.4.240.0030.02311.58
5.4.230.0040.02211.55
5.4.220.0070.01911.67
5.4.210.0060.02211.69
5.4.200.0020.02211.55
5.4.190.0050.02211.68
5.4.180.0060.02011.75
5.4.170.0090.01811.68
5.4.160.0050.02111.64
5.4.150.0020.02211.71
5.4.140.0040.02111.59
5.4.130.0080.01811.69
5.4.120.0040.02211.54
5.4.110.0060.01911.53
5.4.100.0030.02211.44
5.4.90.0040.02111.56
5.4.80.0040.02011.64
5.4.70.0040.02011.57
5.4.60.0030.02011.57
5.4.50.0040.02211.41
5.4.40.0060.01911.55
5.4.30.0030.02111.41
5.4.20.0050.02211.61
5.4.10.0070.01811.42
5.4.00.0040.02011.13
5.3.290.0040.04012.80
5.3.280.0070.03612.71
5.3.270.0060.03812.73
5.3.260.0070.03712.72
5.3.250.0060.03712.72
5.3.240.0050.03912.71
5.3.230.0060.03712.71
5.3.220.0090.03312.68
5.3.210.0040.04012.68
5.3.200.0070.03512.68
5.3.190.0070.03712.68
5.3.180.0080.03412.67
5.3.170.0080.03612.67
5.3.160.0040.03912.67
5.3.150.0050.03712.68
5.3.140.0080.03412.66
5.3.130.0020.04212.66
5.3.120.0060.03812.66
5.3.110.0060.03912.65
5.3.100.0110.03112.13
5.3.90.0070.03512.11
5.3.80.0050.03712.10
5.3.70.0070.03612.10
5.3.60.0100.03212.08
5.3.50.0080.03312.03
5.3.40.0070.03512.03
5.3.30.0060.03711.98
5.3.20.0110.03111.77
5.3.10.0020.03911.73
5.3.00.0070.03911.72
5.2.170.0020.0329.23
5.2.160.0050.0289.23
5.2.150.0030.0319.23
5.2.140.0040.0309.22
5.2.130.0050.0289.18
5.2.120.0080.0259.18
5.2.110.0050.0299.19
5.2.100.0060.0279.18
5.2.90.0040.0299.18
5.2.80.0020.0329.18
5.2.70.0030.0319.18
5.2.60.0040.0299.14
5.2.50.0050.0299.11
5.2.40.0040.0299.08
5.2.30.0050.0299.05
5.2.20.0080.0259.05
5.2.10.0030.0348.95
5.2.00.0030.0308.81
5.1.60.0020.0258.09
5.1.50.0080.0218.09
5.1.40.0040.0248.07
5.1.30.0060.0258.42
5.1.20.0030.0278.45
5.1.10.0030.0268.17
5.1.00.0020.0288.17
5.0.50.0060.0186.64
5.0.40.0030.0206.50
5.0.30.0030.0336.31
5.0.20.0050.0176.28
5.0.10.0030.0206.26
5.0.00.0040.0296.25
4.4.90.0030.0144.78
4.4.80.0030.0144.76
4.4.70.0030.0144.76
4.4.60.0030.0144.75
4.4.50.0020.0154.77
4.4.40.0020.0254.70
4.4.30.0020.0164.76
4.4.20.0050.0134.84
4.4.10.0030.0154.85
4.4.00.0040.0234.76
4.3.110.0020.0164.67
4.3.100.0040.0134.66
4.3.90.0030.0144.63
4.3.80.0020.0254.58
4.3.70.0030.0144.63
4.3.60.0020.0154.63
4.3.50.0030.0154.62
4.3.40.0040.0224.54
4.3.30.0030.0153.28
4.3.20.0020.0153.26
4.3.10.0010.0163.22
4.3.00.0100.0237.20

preferences:
42.46 ms | 400 KiB | 5 Q