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 $foo; 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() { return (string) $this->bar; } } $foo = MyValueObject::fromParams(array('foo' => 'foo', 'bar' => 'bar', 'meh' => 'meh')); $foo->setFoo('newfoo'); $foo->setDog('dog'); echo $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.0180.00018.68
8.3.50.0130.00821.21
8.3.40.0150.00418.96
8.3.30.0110.00419.22
8.3.20.0120.00620.34
8.3.10.0040.00423.41
8.3.00.0040.00419.26
8.2.180.0110.00716.75
8.2.170.0090.00622.96
8.2.160.0100.00720.39
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0030.00622.18
8.2.110.0000.00820.42
8.2.100.0110.00018.09
8.2.90.0050.00319.15
8.2.80.0050.00517.97
8.2.70.0030.00617.75
8.2.60.0050.00318.04
8.2.50.0030.00518.07
8.2.40.0000.00819.95
8.2.30.0030.00618.14
8.2.20.0000.00717.82
8.2.10.0070.00018.14
8.2.00.0000.00817.76
8.1.280.0140.00725.92
8.1.270.0080.00022.32
8.1.260.0000.00726.35
8.1.250.0050.00328.09
8.1.240.0000.00823.84
8.1.230.0110.00019.24
8.1.220.0000.00817.77
8.1.210.0060.00318.77
8.1.200.0080.00317.47
8.1.190.0040.00417.35
8.1.180.0090.00018.10
8.1.170.0000.00818.59
8.1.160.0070.00022.00
8.1.150.0000.00718.89
8.1.140.0050.00317.48
8.1.130.0030.00317.89
8.1.120.0000.00717.56
8.1.110.0040.00417.49
8.1.100.0070.00017.43
8.1.90.0000.00717.52
8.1.80.0050.00317.53
8.1.70.0030.00317.43
8.1.60.0000.00817.67
8.1.50.0060.00317.55
8.1.40.0040.00417.46
8.1.30.0000.01017.69
8.1.20.0040.00417.63
8.1.10.0060.00317.54
8.1.00.0060.00317.48
8.0.300.0070.00018.77
8.0.290.0040.00417.00
8.0.280.0030.00318.52
8.0.270.0080.00017.20
8.0.260.0030.00317.33
8.0.250.0040.00417.09
8.0.240.0040.00416.96
8.0.230.0030.00316.91
8.0.220.0040.00416.82
8.0.210.0030.00316.93
8.0.200.0000.00616.96
8.0.190.0070.00017.00
8.0.180.0050.00316.91
8.0.170.0080.00016.96
8.0.160.0070.00416.89
8.0.150.0040.00416.94
8.0.140.0040.00416.81
8.0.130.0050.00213.43
8.0.120.0000.00816.95
8.0.110.0000.00816.93
8.0.100.0020.00516.95
8.0.90.0000.00816.90
8.0.80.0080.00816.89
8.0.70.0000.00716.82
8.0.60.0000.00716.77
8.0.50.0040.00416.91
8.0.30.0130.00817.25
8.0.20.0090.01017.40
8.0.10.0040.00417.14
8.0.00.0060.01116.96
7.4.330.0000.00515.01
7.4.320.0000.00616.59
7.4.300.0030.00316.71
7.4.290.0080.00016.52
7.4.280.0030.00716.48
7.4.270.0040.00416.71
7.4.260.0000.01016.67
7.4.250.0000.00716.44
7.4.240.0040.00416.62
7.4.230.0040.00416.41
7.4.220.0140.01116.66
7.4.210.0090.00616.68
7.4.200.0000.00716.70
7.4.160.0070.01016.50
7.4.150.0070.01117.40
7.4.140.0120.00617.86
7.4.130.0100.01016.66
7.4.120.0090.00816.58
7.4.110.0050.01616.52
7.4.100.0140.00316.58
7.4.90.0120.00616.64
7.4.80.0050.01319.39
7.4.70.0110.01016.66
7.4.60.0030.01416.54
7.4.50.0040.00416.47
7.4.40.0110.00616.68
7.4.30.0110.01116.64
7.4.10.0030.01414.96
7.4.00.0080.00614.92
7.3.330.0000.00613.12
7.3.320.0000.00613.36
7.3.310.0070.00016.38
7.3.300.0020.00516.29
7.3.290.0100.01016.26
7.3.280.0040.01216.36
7.3.270.0110.00717.40
7.3.260.0070.01016.40
7.3.250.0100.00816.54
7.3.240.0040.01316.58
7.3.230.0060.01116.53
7.3.210.0060.01216.49
7.3.200.0060.01519.39
7.3.190.0070.01116.34
7.3.180.0070.01016.57
7.3.170.0150.00616.58
7.3.160.0080.00816.32
7.3.130.0060.01214.62
7.3.120.0100.01014.80
7.3.110.0060.01215.09
7.3.100.0040.01114.65
7.3.90.0070.00714.97
7.3.80.0080.00814.56
7.3.70.0060.00915.04
7.3.60.0100.00315.04
7.3.50.0000.00914.69
7.3.40.0060.01014.57
7.3.30.0080.00514.57
7.3.20.0040.00416.75
7.3.10.0030.01216.75
7.3.00.0130.00016.78
7.2.330.0190.00316.74
7.2.320.0140.00316.78
7.2.310.0000.01716.62
7.2.300.0000.01616.87
7.2.290.0090.00916.72
7.2.260.0070.01015.18
7.2.250.0070.01115.00
7.2.240.0000.01515.13
7.2.230.0060.00915.29
7.2.220.0000.01915.02
7.2.210.0030.01014.96
7.2.200.0090.00915.05
7.2.190.0030.00715.13
7.2.180.0040.00915.03
7.2.170.0000.01414.90
7.2.160.0060.00615.11
7.2.150.0060.00316.94
7.2.140.0070.00716.92
7.2.130.0090.00916.96
7.2.120.0030.00616.65
7.2.110.0100.00716.94
7.2.100.0080.00817.10
7.2.90.0030.00616.98
7.2.80.0030.01017.02
7.2.70.0110.00416.79
7.2.60.0100.00017.05
7.2.50.0040.00816.71
7.2.40.0030.00617.04
7.2.30.0070.00717.09
7.2.20.0060.00916.75
7.2.10.0070.01017.05
7.2.00.0030.01018.04
7.1.330.0040.01415.78
7.1.320.0030.01015.86
7.1.310.0030.00615.89
7.1.300.0000.01015.77
7.1.290.0080.00815.87
7.1.280.0070.00715.88
7.1.270.0000.01515.95
7.1.260.0100.00715.73
7.1.250.0060.00615.86
7.1.240.0120.00315.99
7.1.230.0040.00815.93
7.1.220.0050.00515.84
7.1.210.0000.01215.91
7.1.200.0000.01315.54
7.1.190.0120.00315.88
7.1.180.0070.00315.87
7.1.170.0030.01115.56
7.1.160.0030.00715.72
7.1.150.0060.00315.69
7.1.140.0060.00715.77
7.1.130.0030.01015.66
7.1.120.0040.00915.60
7.1.110.0100.00315.85
7.1.100.0050.00516.95
7.1.90.0040.01215.92
7.1.80.0050.00515.93
7.1.70.0020.00616.46
7.1.60.0110.00917.50
7.1.50.0050.00416.22
7.1.40.0060.00615.79
7.1.30.0080.00415.63
7.1.20.0080.00815.46
7.1.10.0100.00015.65
7.1.00.0070.04019.11
7.0.330.0040.01415.35
7.0.320.0080.00415.60
7.0.310.0000.01015.48
7.0.300.0120.00415.20
7.0.290.0070.00315.21
7.0.280.0090.00015.46
7.0.270.0070.00715.42
7.0.260.0100.00715.23
7.0.250.0030.01015.23
7.0.240.0040.00815.38
7.0.230.0110.00415.48
7.0.220.0030.00715.43
7.0.210.0090.00315.46
7.0.200.0020.00915.92
7.0.190.0080.00315.47
7.0.180.0040.00415.51
7.0.170.0030.01215.48
7.0.160.0030.01015.21
7.0.150.0080.00415.55
7.0.140.0080.03318.61
7.0.130.0040.00815.64
7.0.120.0000.01115.11
7.0.110.0070.00715.57
7.0.100.0030.01015.36
7.0.90.0030.00915.29
7.0.80.0060.00615.48
7.0.70.0040.00415.52
7.0.60.0040.02617.72
7.0.50.0050.04816.71
7.0.40.0060.04316.87
7.0.30.0230.04216.85
7.0.20.0170.02916.64
7.0.10.0060.02516.75
7.0.00.0050.04916.87
5.6.400.0040.01214.62
5.6.390.0120.00314.77
5.6.380.0000.01414.50
5.6.370.0070.00714.29
5.6.360.0000.01014.48
5.6.350.0000.01814.27
5.6.340.0000.01014.19
5.6.330.0030.00714.71
5.6.320.0110.00314.66
5.6.310.0100.00314.76
5.6.300.0060.00614.40
5.6.290.0000.00814.51
5.6.280.0030.01014.40
5.6.270.0000.01514.47
5.6.260.0130.00314.05
5.6.250.0060.00914.31
5.6.240.0000.01814.38
5.6.230.0000.00914.73
5.6.220.0100.00314.34
5.6.210.0070.03617.64
5.6.200.0100.03316.22
5.6.190.0080.02117.61
5.6.180.0130.03317.38
5.6.170.0150.04217.44
5.6.160.0060.04117.61
5.6.150.0130.03616.25
5.6.140.0100.03916.21
5.6.130.0030.02516.41
5.6.120.0050.02517.76
5.6.110.0040.05217.78
5.6.100.0060.02617.68
5.6.90.0040.03817.67
5.6.80.0060.02517.44
5.6.70.0070.01014.38
5.6.60.0090.00614.41
5.6.50.0080.00314.66
5.6.40.0100.00714.28
5.6.30.0090.00614.37
5.6.20.0060.00314.42
5.6.10.0000.01314.41
5.6.00.0030.01014.36
5.5.380.0140.00014.29
5.5.370.0080.00414.41
5.5.360.0070.00314.22
5.5.350.0080.04117.60
5.5.340.0120.03716.23
5.5.330.0070.04417.32
5.5.320.0190.02617.32
5.5.310.0150.02517.36
5.5.300.0080.04116.11
5.5.290.0080.04216.17
5.5.280.0090.03017.68
5.5.270.0040.04917.69
5.5.260.0050.02317.61
5.5.250.0070.02517.44
5.5.240.0180.03717.29
5.5.230.0040.00814.27
5.5.220.0030.01014.48
5.5.210.0030.00614.48
5.5.200.0070.01014.34
5.5.190.0030.00914.35
5.5.180.0070.00714.27
5.5.170.0070.00314.19
5.5.160.0100.00714.16
5.5.150.0100.00614.48
5.5.140.0030.01314.55
5.5.130.0130.00314.09
5.5.120.0070.00714.11
5.5.110.0090.00614.23
5.5.100.0040.00814.50
5.5.90.0070.01014.48
5.5.80.0070.00314.39
5.5.70.0060.00914.18
5.5.60.0060.00614.24
5.5.50.0030.01514.12
5.5.40.0060.01214.49
5.5.30.0060.01214.04
5.5.20.0070.00714.51
5.5.10.0040.00814.25
5.5.00.0110.00413.98
5.4.450.0520.03316.21
5.4.440.0270.03516.13
5.4.430.0030.03816.04
5.4.420.0400.00316.10
5.4.410.0320.00316.18
5.4.400.0400.00415.93
5.4.390.0340.00115.92
5.4.380.0330.00315.92
5.4.370.0330.00315.93
5.4.360.0360.00415.89
5.4.350.0330.00415.95
5.4.340.0050.02012.41
5.4.330.0060.00012.79
5.4.320.0040.02312.66
5.4.310.0050.02412.66
5.4.300.0060.02112.66
5.4.290.0040.02112.65
5.4.280.0040.02212.60
5.4.270.0050.02312.61
5.4.260.0050.02212.60
5.4.250.0050.02212.60
5.4.240.0070.02012.60
5.4.230.0080.02212.60
5.4.220.0070.02012.60
5.4.210.0040.02312.60
5.4.200.0090.02212.60
5.4.190.0070.01912.60
5.4.180.0060.02212.60
5.4.170.0050.02412.60
5.4.160.0100.02112.60
5.4.150.0040.02312.60
5.4.140.0060.02312.44
5.4.130.0040.02312.43
5.4.120.0080.01912.42
5.4.110.0050.02312.41
5.4.100.0080.01912.41
5.4.90.0020.02712.41
5.4.80.0050.02312.41
5.4.70.0070.02012.41
5.4.60.0100.01612.41
5.4.50.0060.02112.41
5.4.40.0040.02212.40
5.4.30.0070.02212.40
5.4.20.0060.02312.40
5.4.10.0050.01912.40
5.4.00.0050.02812.15
5.3.290.0110.04312.80
5.3.280.0050.04012.71
5.3.270.0050.04112.72
5.3.260.0070.03812.72
5.3.250.0060.04512.72
5.3.240.0050.03812.72
5.3.230.0050.03812.71
5.3.220.0060.03712.68
5.3.210.0060.03912.68
5.3.200.0060.03712.68
5.3.190.0090.03412.68
5.3.180.0090.03712.67
5.3.170.0050.04212.67
5.3.160.0090.03412.67
5.3.150.0060.03712.67
5.3.140.0030.03912.66
5.3.130.0070.03712.66
5.3.120.0060.04012.65
5.3.110.0130.03112.66
5.3.100.0060.03612.12
5.3.90.0060.03612.08
5.3.80.0080.03412.07
5.3.70.0030.03812.07
5.3.60.0030.03912.07
5.3.50.0090.03312.00
5.3.40.0070.03812.00
5.3.30.0110.03711.95
5.3.20.0070.03411.72
5.3.10.0060.03411.70
5.3.00.0070.03411.68
5.2.170.0040.0319.18
5.2.160.0070.0279.18
5.2.150.0030.0339.18
5.2.140.0040.0319.18
5.2.130.0030.0319.14
5.2.120.0110.0259.14
5.2.110.0080.0289.15
5.2.100.0090.0339.14
5.2.90.0060.0319.14
5.2.80.0060.0359.14
5.2.70.0100.0279.13
5.2.60.0050.0299.09
5.2.50.0030.0329.06
5.2.40.0010.0359.03
5.2.30.0040.0339.01
5.2.20.0040.0299.00
5.2.10.0030.0308.92
5.2.00.0030.0318.78
5.1.60.0040.0248.07
5.1.50.0060.0228.06
5.1.40.0060.0228.04
5.1.30.0070.0238.40
5.1.20.0020.0288.41
5.1.10.0030.0278.14
5.1.00.0050.0248.15
5.0.50.0020.0226.62
5.0.40.0050.0176.48
5.0.30.0040.0316.30
5.0.20.0030.0196.26
5.0.10.0040.0196.24
5.0.00.0040.0306.24
4.4.90.0040.0144.78
4.4.80.0030.0154.76
4.4.70.0040.0144.75
4.4.60.0030.0154.76
4.4.50.0040.0144.77
4.4.40.0020.0254.71
4.4.30.0040.0144.76
4.4.20.0020.0164.84
4.4.10.0040.0144.85
4.4.00.0050.0234.76
4.3.110.0040.0144.67
4.3.100.0030.0144.66
4.3.90.0030.0144.63
4.3.80.0040.0234.58
4.3.70.0040.0134.63
4.3.60.0010.0164.63
4.3.50.0020.0164.63
4.3.40.0020.0244.54
4.3.30.0020.0193.28
4.3.20.0030.0193.26
4.3.10.0020.0163.22
4.3.00.0030.0237.23

preferences:
65.01 ms | 401 KiB | 5 Q