3v4l.org

run code in 300+ PHP versions simultaneously
<?php 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); } } } interface DataTransferObjectInterface { public static function fromParams(array $params); public function asArray(); } abstract class AbstractDataTransferObject implements DataTransferObjectInterface { use ImmutableFromParams; public function asArray() { return get_object_vars($this); } } final class MyDataTransferObject extends AbstractDataTransferObject { protected $fooBoo; protected $bar; protected function setBar($value) { $this->bar = $value; } } $foo = MyDataTransferObject::fromParams(array('foo' => 'foo', 'bar' => 'bar', 'meh' => 'meh')); $foo->setFoo('newfoo'); $foo->setDog('dog'); var_dump($foo->asArray()); interface ValueObjectInterface { public static function fromParams(array $params); public function __toString(); } abstract class AbstractValueObject implements ValueObjectInterface { use ImmutableFromParams; abstract public function __toString(); } final class MyValueObject extends AbstractValueObject { protected $bar; protected function setBar($value) { $this->bar = $value; } public function __toString() { echo $bar; } } $foo = MyValueObject::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.90.0120.00318.50
8.3.80.0060.00318.56
8.3.70.0090.00916.75
8.3.60.0040.01118.55
8.3.50.0140.00721.32
8.3.40.0120.00318.79
8.3.30.0070.00719.08
8.3.20.0130.00620.18
8.3.10.0050.00323.48
8.3.00.0050.00319.26
8.2.210.0080.00026.77
8.2.200.0090.00016.75
8.2.190.0150.00316.63
8.2.180.0120.00318.16
8.2.170.0070.00722.96
8.2.160.0070.01020.35
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00926.16
8.2.120.0070.00320.36
8.2.110.0000.01021.06
8.2.100.0110.00017.78
8.2.90.0040.00420.45
8.2.80.0030.00518.04
8.2.70.0030.00617.93
8.2.60.0040.00418.03
8.2.50.0030.00618.10
8.2.40.0050.00320.66
8.2.30.0000.00718.05
8.2.20.0030.00617.68
8.2.10.0050.00218.14
8.2.00.0040.00417.80
8.1.290.0090.00018.88
8.1.280.0090.01225.92
8.1.270.0030.00622.32
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0110.00021.01
8.1.230.0040.00721.16
8.1.220.0040.00417.79
8.1.210.0060.00319.16
8.1.200.0090.00017.47
8.1.190.0000.01017.35
8.1.180.0000.00718.10
8.1.170.0060.00318.78
8.1.160.0040.00422.25
8.1.150.0000.00718.95
8.1.140.0000.00817.52
8.1.130.0000.00717.94
8.1.120.0040.00417.43
8.1.110.0000.00817.43
8.1.100.0000.00717.45
8.1.90.0000.00717.51
8.1.80.0020.00517.49
8.1.70.0070.00017.39
8.1.60.0060.00617.72
8.1.50.0040.00417.63
8.1.40.0000.00917.59
8.1.30.0030.00617.68
8.1.20.0000.00817.70
8.1.10.0040.00417.67
8.1.00.0000.00817.54
8.0.300.0000.00720.10
8.0.290.0070.00316.88
8.0.280.0000.00718.50
8.0.270.0000.00717.38
8.0.260.0000.00617.32
8.0.250.0030.00517.04
8.0.240.0040.00416.97
8.0.230.0070.00017.07
8.0.220.0030.00317.04
8.0.210.0030.00316.96
8.0.200.0030.00317.04
8.0.190.0040.00417.03
8.0.180.0040.00416.88
8.0.170.0030.00616.96
8.0.160.0000.01216.93
8.0.150.0040.00416.86
8.0.140.0080.00016.95
8.0.130.0000.00613.45
8.0.120.0000.00816.91
8.0.110.0070.00316.79
8.0.100.0040.00416.97
8.0.90.0040.00416.85
8.0.80.0080.00816.88
8.0.70.0000.00816.91
8.0.60.0040.00416.90
8.0.50.0040.00416.80
8.0.30.0120.00917.26
8.0.20.0050.01717.40
8.0.10.0030.00517.14
8.0.00.0110.00816.96
7.4.330.0050.00015.15
7.4.320.0000.00616.58
7.4.300.0060.00016.58
7.4.290.0000.00816.67
7.4.280.0040.00416.41
7.4.270.0040.00416.69
7.4.260.0090.00016.54
7.4.250.0040.00416.53
7.4.240.0020.00616.66
7.4.230.0040.00416.60
7.4.220.0110.01416.75
7.4.210.0100.00716.56
7.4.200.0040.00416.77
7.4.160.0060.00916.36
7.4.150.0100.00717.40
7.4.140.0160.00817.86
7.4.130.0050.01216.70
7.4.120.0060.01016.67
7.4.110.0100.01316.55
7.4.100.0130.00616.45
7.4.90.0100.00716.57
7.4.80.0030.01419.39
7.4.70.0050.01116.68
7.4.60.0060.01116.48
7.4.50.0040.00416.66
7.4.40.0120.00616.73
7.4.30.0100.00716.46
7.4.00.0100.00614.95
7.3.330.0050.00013.15
7.3.320.0060.00013.17
7.3.310.0050.00316.21
7.3.300.0000.00716.35
7.3.290.0080.00816.28
7.3.280.0080.00816.29
7.3.270.0140.00417.40
7.3.260.0130.00816.68
7.3.250.0070.01016.52
7.3.240.0140.00416.27
7.3.230.0070.01116.55
7.3.210.0130.01016.62
7.3.200.0160.00319.39
7.3.190.0070.01116.35
7.3.180.0100.00616.63
7.3.170.0170.00616.59
7.3.160.0030.01316.55
7.3.120.0090.00915.08
7.3.110.0070.01114.55
7.3.100.0060.01314.96
7.3.90.0080.00514.99
7.3.80.0060.00914.86
7.3.70.0070.00714.89
7.3.60.0030.00614.96
7.3.50.0070.00714.77
7.3.40.0040.01115.00
7.3.30.0060.00315.04
7.3.20.0080.00616.54
7.3.10.0060.00816.50
7.3.00.0120.00616.48
7.2.330.0090.01516.85
7.2.320.0060.01316.78
7.2.310.0140.00716.70
7.2.300.0060.01316.75
7.2.290.0140.00316.73
7.2.250.0100.00715.19
7.2.240.0160.00415.17
7.2.230.0060.00915.02
7.2.220.0080.00815.09
7.2.210.0140.00715.00
7.2.200.0060.00315.08
7.2.190.0030.01315.25
7.2.180.0070.00715.19
7.2.170.0060.00915.12
7.2.160.0030.00915.16
7.2.150.0030.00716.91
7.2.140.0000.00916.68
7.2.130.0090.00516.75
7.2.120.0050.01116.66
7.2.110.0110.00816.79
7.2.100.0090.00916.75
7.2.90.0100.00816.68
7.2.80.0050.01316.71
7.2.70.0060.01116.70
7.2.60.0090.00816.79
7.2.50.0160.00616.66
7.2.40.0190.00416.79
7.2.30.0120.01116.82
7.2.20.0110.00816.83
7.2.10.0130.00916.77
7.2.00.0090.00717.63
7.1.330.0100.00715.68
7.1.320.0040.01115.73
7.1.310.0040.00815.64
7.1.300.0030.00715.50
7.1.290.0070.00315.65
7.1.280.0120.00415.52
7.1.270.0120.00615.86
7.1.260.0070.00715.73
7.1.250.0050.00715.56
7.1.240.0090.00615.74
7.1.230.0070.01015.80
7.1.220.0030.01215.88
7.1.210.0040.00715.52
7.1.200.0110.00515.64
7.1.190.0070.00415.92
7.1.180.0090.00615.89
7.1.170.0070.00715.91
7.1.160.0030.01015.88
7.1.150.0060.01015.83
7.1.140.0100.00315.71
7.1.130.0140.00315.62
7.1.120.0060.00615.85
7.1.110.0080.00815.66
7.1.100.0050.00816.89
7.1.90.0000.01415.82
7.1.80.0030.00715.78
7.1.70.0060.00616.47
7.1.60.0100.01017.31
7.1.50.0060.00416.28
7.1.40.0030.01015.62
7.1.30.0080.00315.66
7.1.20.0060.00615.97
7.1.10.0060.00615.66
7.1.00.0050.03918.97
7.0.330.0000.00815.37
7.0.320.0060.00515.51
7.0.310.0040.00815.19
7.0.300.0100.00315.65
7.0.290.0030.00715.45
7.0.280.0030.01015.33
7.0.270.0130.00315.38
7.0.260.0100.00315.39
7.0.250.0030.01015.50
7.0.240.0030.01015.59
7.0.230.0060.00915.33
7.0.220.0090.00015.45
7.0.210.0080.00315.44
7.0.200.0050.00815.91
7.0.190.0060.00615.43
7.0.180.0100.00315.39
7.0.170.0090.00615.21
7.0.160.0060.00915.60
7.0.150.0070.00315.14
7.0.140.0070.03518.69
7.0.130.0110.00015.57
7.0.120.0080.00815.22
7.0.110.0030.01415.44
7.0.100.0080.00315.45
7.0.90.0030.01215.58
7.0.80.0000.01015.44
7.0.70.0030.01015.31
7.0.60.0030.02317.79
7.0.50.0070.04316.73
7.0.40.0050.02616.82
7.0.30.0270.02916.89
7.0.20.0150.02316.86
7.0.10.0120.01716.97
7.0.00.0050.04816.83
5.6.400.0030.01214.39
5.6.390.0030.01114.50
5.6.380.0060.00914.53
5.6.370.0030.00614.39
5.6.360.0040.01114.43
5.6.350.0080.00614.60
5.6.340.0130.00314.43
5.6.330.0000.01614.71
5.6.320.0000.01114.54
5.6.310.0070.00314.56
5.6.300.0060.00314.32
5.6.290.0030.00814.59
5.6.280.0040.04217.62
5.6.270.0070.01014.27
5.6.260.0000.01414.72
5.6.250.0190.00014.61
5.6.240.0040.00414.35
5.6.230.0050.00514.52
5.6.220.0030.00914.54
5.6.210.0080.04617.59
5.6.200.0030.03416.29
5.6.190.0050.02417.48
5.6.180.0170.04317.45
5.6.170.0170.02517.61
5.6.160.0030.03817.34
5.6.150.0090.04216.32
5.6.140.0130.03516.33
5.6.130.0040.02616.28
5.6.120.0090.02217.57
5.6.110.0190.03417.84
5.6.100.0070.04517.76
5.6.90.0050.04717.79
5.6.80.0100.01817.26
5.6.70.0030.00614.21
5.6.60.0000.01614.28
5.6.50.0070.00714.27
5.6.40.0000.01514.47
5.6.30.0000.01314.19
5.6.20.0030.00614.38
5.6.10.0040.01114.63
5.6.00.0000.00914.33
5.5.380.0060.00914.54
5.5.370.0060.00914.49
5.5.360.0030.01014.43
5.5.350.0050.04517.35
5.5.340.0110.02316.18
5.5.330.0050.03817.52
5.5.320.0230.02017.29
5.5.310.0180.04117.55
5.5.300.0080.04416.26
5.5.290.0080.04316.23
5.5.280.0100.02717.86
5.5.270.0040.02717.70
5.5.260.0040.02417.72
5.5.250.0070.02517.62
5.5.240.0170.02817.38
5.5.230.0000.01514.31
5.5.220.0070.00714.27
5.5.210.0080.00414.27
5.5.200.0030.01314.43
5.5.190.0030.01514.37
5.5.180.0030.00714.43
5.5.170.0030.01014.38
5.5.160.0070.00713.88
5.5.150.0000.01014.41
5.5.140.0030.01014.52
5.5.130.0040.00414.55
5.5.120.0000.01314.28
5.5.110.0070.00414.34
5.5.100.0070.00314.21
5.5.90.0150.00314.12
5.5.80.0040.00814.48
5.5.70.0090.00314.22
5.5.60.0110.00414.45
5.5.50.0070.01014.44
5.5.40.0070.00714.15
5.5.30.0100.00014.44
5.5.20.0060.00614.16
5.5.10.0030.01014.04
5.5.00.0090.00014.01
5.4.450.0120.03516.13
5.4.440.0400.03016.21
5.4.430.0030.03616.07
5.4.420.0330.00416.15
5.4.410.0370.00216.11
5.4.400.0370.00516.02
5.4.390.0330.00316.02
5.4.380.0350.00415.99
5.4.370.0350.00215.91
5.4.360.0320.00415.94
5.4.350.0320.00715.90
5.4.340.0030.02212.42
5.4.330.0000.01312.80
5.4.320.0040.02012.66
5.4.310.0040.02312.66
5.4.300.0050.02312.67
5.4.290.0040.02712.66
5.4.280.0040.02112.61
5.4.270.0050.01912.61
5.4.260.0060.02112.61
5.4.250.0070.02012.61
5.4.240.0040.02112.61
5.4.230.0090.01812.61
5.4.220.0040.02112.60
5.4.210.0040.02112.61
5.4.200.0100.01712.61
5.4.190.0040.02212.61
5.4.180.0060.02212.60
5.4.170.0050.02712.61
5.4.160.0030.02312.61
5.4.150.0090.01912.61
5.4.140.0040.02312.45
5.4.130.0060.02012.44
5.4.120.0020.02312.42
5.4.110.0070.02012.42
5.4.100.0060.02412.42
5.4.90.0080.02112.42
5.4.80.0060.02212.42
5.4.70.0070.01612.42
5.4.60.0040.01912.42
5.4.50.0040.02012.42
5.4.40.0050.02112.41
5.4.30.0080.01912.41
5.4.20.0050.02112.41
5.4.10.0050.02212.41
5.4.00.0020.02412.16
5.3.290.0070.04112.80
5.3.280.0060.03612.71
5.3.270.0080.03812.72
5.3.260.0110.04312.72
5.3.250.0060.03512.72
5.3.240.0070.03512.71
5.3.230.0070.04312.71
5.3.220.0070.03912.68
5.3.210.0070.03712.68
5.3.200.0040.03712.68
5.3.190.0060.04312.68
5.3.180.0040.03612.67
5.3.170.0030.03812.67
5.3.160.0050.03812.68
5.3.150.0080.03512.68
5.3.140.0090.03312.66
5.3.130.0050.03912.66
5.3.120.0050.03912.66
5.3.110.0080.04012.66
5.3.100.0030.03912.12
5.3.90.0070.04212.09
5.3.80.0090.03612.07
5.3.70.0110.03012.07
5.3.60.0030.03812.06
5.3.50.0110.03312.00
5.3.40.0070.03812.00
5.3.30.0060.03811.95
5.3.20.0040.03711.73
5.3.10.0040.03911.70
5.3.00.0050.04011.68
5.2.170.0060.0289.19
5.2.160.0050.0299.19
5.2.150.0090.0319.19
5.2.140.0040.0309.18
5.2.130.0040.0289.14
5.2.120.0020.0299.14
5.2.110.0030.0329.15
5.2.100.0050.0279.14
5.2.90.0060.0279.14
5.2.80.0040.0329.14
5.2.70.0090.0349.14
5.2.60.0050.0339.10
5.2.50.0060.0279.07
5.2.40.0040.0289.04
5.2.30.0050.0289.02
5.2.20.0030.0299.00
5.2.10.0040.0278.92
5.2.00.0050.0278.79
5.1.60.0050.0228.07
5.1.50.0060.0228.06
5.1.40.0030.0258.05
5.1.30.0050.0258.40
5.1.20.0020.0278.42
5.1.10.0040.0318.15
5.1.00.0050.0238.15
5.0.50.0050.0196.62
5.0.40.0030.0196.48
5.0.30.0040.0296.30
5.0.20.0040.0186.26
5.0.10.0040.0246.25
5.0.00.0030.0346.24
4.4.90.0030.0154.78
4.4.80.0060.0124.75
4.4.70.0010.0174.75
4.4.60.0020.0154.76
4.4.50.0050.0154.77
4.4.40.0050.0314.71
4.4.30.0060.0194.76
4.4.20.0030.0204.84
4.4.10.0020.0154.85
4.4.00.0040.0274.76
4.3.110.0040.0144.67
4.3.100.0030.0164.66
4.3.90.0000.0164.64
4.3.80.0020.0244.59
4.3.70.0010.0154.63
4.3.60.0010.0164.62
4.3.50.0040.0134.63
4.3.40.0010.0254.54
4.3.30.0010.0173.28
4.3.20.0020.0163.26
4.3.10.0010.0163.22
4.3.00.0000.0237.23

preferences:
32.23 ms | 401 KiB | 5 Q