3v4l.org

run code in 300+ PHP versions simultaneously
<?php class GenericCollection extends \SplDoublyLinkedList { private $className; public function __construct($className, $data = []) { if (!class_exists($className)) { throw new \LogicException('Invalid class name: ' . $className); } $this->className = $className; $this->items = new \SplDoublyLinkedList; foreach ($data as $item) { $this->push($item); } } private function checkItemIsInstanceOfCorrectClass($item) { if (!$item instanceof $this->className) { throw new \LogicException('Items in this collection must be instances of ' . $this->className); } } public function getClassName() { return $this->className; } public function add($item) { $this->checkItemIsInstanceOfCorrectClass($item); parent::add($item); } public function push($item) { $this->checkItemIsInstanceOfCorrectClass($item); parent::push($item); } public function unshift($item) { $this->checkItemIsInstanceOfCorrectClass($item); parent::unshift($item); } public function offsetSet($offset, $item) { $this->checkItemIsInstanceOfCorrectClass($item); parent::offsetSet($offset, $item); } } class Foo {} class Bar {} $col = new GenericCollection(Foo::class, [new Foo, new Foo]); $col->push(new Foo); $col[] = new Foo; foreach ($col as $foo) { var_dump($foo); } $col->push(new Bar);

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.01116.75
8.3.50.0140.00522.79
8.3.40.0090.00618.86
8.3.30.0120.00918.96
8.3.20.0080.00020.35
8.3.10.0000.00723.52
8.3.00.0000.00819.25
8.2.180.0030.01016.50
8.2.170.0030.01022.96
8.2.160.0040.01119.23
8.2.150.0040.00424.18
8.2.140.0110.00024.66
8.2.130.0140.00026.16
8.2.120.0040.00420.96
8.2.110.0030.00622.27
8.2.100.0000.01217.78
8.2.90.0000.00819.15
8.2.80.0040.00717.97
8.2.70.0060.00317.50
8.2.60.0030.00617.68
8.2.50.0000.00818.07
8.2.40.0050.00319.76
8.2.30.0050.00617.88
8.2.20.0000.00717.66
8.2.10.0020.00518.02
8.2.00.0000.00717.60
8.1.280.0090.00625.92
8.1.270.0030.00523.92
8.1.260.0080.00026.35
8.1.250.0050.00328.09
8.1.240.0050.00523.80
8.1.230.0040.00719.05
8.1.220.0080.00017.74
8.1.210.0000.00818.77
8.1.200.0020.01017.23
8.1.190.0000.00816.98
8.1.180.0040.00418.10
8.1.170.0040.00418.31
8.1.160.0050.00221.90
8.1.150.0040.00418.84
8.1.140.0000.00717.39
8.1.130.0030.00317.76
8.1.120.0000.00717.27
8.1.110.0020.00517.36
8.1.100.0080.00017.38
8.1.90.0000.00717.33
8.1.80.0070.00017.36
8.1.70.0030.00617.31
8.1.60.0090.00017.41
8.1.50.0070.00017.39
8.1.40.0030.00517.48
8.1.30.0030.00617.48
8.1.20.0000.00717.49
8.1.10.0040.00417.32
8.1.00.0040.00417.25
8.0.300.0030.00618.77
8.0.290.0040.00416.63
8.0.280.0040.00418.24
8.0.270.0000.00717.09
8.0.260.0000.00617.16
8.0.250.0030.00316.89
8.0.240.0050.00216.82
8.0.230.0030.00316.92
8.0.220.0000.00716.74
8.0.210.0070.00016.77
8.0.200.0000.00716.97
8.0.190.0000.00816.86
8.0.180.0000.00716.84
8.0.170.0060.00316.84
8.0.160.0040.00416.93
8.0.150.0040.00416.75
8.0.140.0000.00716.86
8.0.130.0030.00313.33
8.0.120.0000.00816.80
8.0.110.0030.00516.88
8.0.100.0040.00416.75
8.0.90.0070.00016.74
8.0.80.0190.00316.73
8.0.70.0040.00416.89
8.0.60.0040.00416.80
8.0.50.0000.00716.88
8.0.30.0140.00816.96
8.0.20.0050.01317.40
8.0.10.0080.00016.84
8.0.00.0090.00916.74
7.4.330.0050.00015.14
7.4.320.0040.00416.62
7.4.300.0030.00316.54
7.4.290.0030.00316.52
7.4.280.0030.00516.60
7.4.270.0000.00716.70
7.4.260.0050.00316.48
7.4.250.0000.00816.65
7.4.240.0020.00616.56
7.4.230.0000.00816.74
7.4.220.0040.01416.62
7.4.210.0110.00316.55
7.4.200.0000.00716.63
7.4.160.0100.00616.56
7.4.150.0040.01417.40
7.4.140.0070.01017.86
7.4.130.0080.00816.58
7.4.120.0090.00716.57
7.4.110.0070.01116.71
7.4.100.0070.01016.71
7.4.90.0060.01116.50
7.4.80.0070.01319.39
7.4.70.0140.00316.57
7.4.60.0060.01016.54
7.4.50.0000.00516.50
7.4.40.0090.00916.70
7.4.30.0080.00816.66
7.4.00.0090.00615.00
7.3.330.0070.00013.47
7.3.320.0060.00013.48
7.3.310.0070.00016.29
7.3.300.0080.00016.47
7.3.290.0110.00816.47
7.3.280.0070.01016.42
7.3.270.0040.01517.40
7.3.260.0140.00916.67
7.3.250.0070.01316.43
7.3.240.0090.00916.52
7.3.230.0090.00916.51
7.3.210.0040.01316.39
7.3.200.0170.00019.39
7.3.190.0040.01316.64
7.3.180.0150.00616.69
7.3.170.0110.00616.64
7.3.160.0130.00316.73
7.2.330.0170.00616.75
7.2.320.0090.00916.81
7.2.310.0060.01116.58
7.2.300.0110.00716.55
7.2.290.0070.01016.75
7.2.60.0030.01217.04
7.2.00.0040.00819.73
7.1.200.0000.01115.65
7.1.100.0000.01217.84
7.1.70.0030.00716.77
7.1.60.0060.01819.40
7.1.50.0100.01016.64
7.1.00.0070.07322.35
7.0.200.0250.00416.65
7.0.140.0070.07322.00
7.0.60.0130.07319.96
7.0.50.0070.08017.91
7.0.40.0100.08320.11
7.0.30.0230.09020.27
7.0.20.0270.07320.33
7.0.10.0130.07720.33
7.0.00.0030.08720.15
5.6.280.0030.07021.04
5.6.210.0070.07020.77
5.6.200.0070.08318.14
5.6.190.0170.04320.60
5.6.180.3130.04320.52
5.6.170.0170.05720.51
5.6.160.0030.04020.51
5.6.150.0130.04318.16
5.6.140.0070.07718.28
5.6.130.0070.06718.28
5.6.120.0030.08721.14
5.6.110.0100.08021.00
5.6.100.0170.06021.15
5.6.90.0130.07321.00
5.6.80.0000.04020.44
5.6.70.4670.04320.38
5.5.350.0270.07320.46
5.5.340.0100.05017.94
5.5.330.0130.07320.13
5.5.320.0430.03320.36
5.5.310.0200.07020.31
5.5.300.0100.06717.96
5.5.290.0000.06017.99
5.5.280.0030.06021.00
5.5.270.0130.07720.82
5.5.260.0030.07021.00
5.5.250.0100.07020.81
5.5.240.0330.06320.03
5.4.450.0300.03719.41
5.4.440.0670.04719.52
5.4.430.0230.04319.47
5.4.420.0270.04319.48
5.4.410.0430.04019.40
5.4.400.0770.03719.23
5.4.390.0730.05319.17
5.4.380.0070.06018.74
5.4.370.0200.06018.72
5.4.360.0200.04718.77
5.4.350.0100.05718.74
5.4.340.0130.05718.66
5.4.320.0050.03612.54
5.4.310.0080.04412.54
5.4.300.0070.03512.54
5.4.290.0050.03812.53
5.4.280.0050.03912.43
5.4.270.0070.05012.43
5.4.260.0070.03512.43
5.4.250.0060.03712.43
5.4.240.0070.04012.43
5.4.230.0070.03812.42
5.4.220.0030.04112.42
5.4.210.0040.03912.42
5.4.200.0040.03712.42
5.4.190.0060.03512.41
5.4.180.0050.03512.41
5.4.170.0070.03412.42
5.4.160.0050.03512.41
5.4.150.0060.03412.41
5.4.140.0050.03612.10
5.4.130.0060.03412.08
5.4.120.0030.03712.05
5.4.110.0080.03712.04
5.4.100.0020.04012.05
5.4.90.0070.04012.04
5.4.80.0040.04112.05
5.4.70.0030.03712.04
5.4.60.0060.04812.04
5.4.50.0080.04612.04
5.4.40.0020.04212.03
5.4.30.0060.03612.03
5.4.20.0040.03612.02
5.4.10.0040.03512.03
5.4.00.0030.04411.52
5.3.290.0040.04912.80
5.3.280.0080.04412.71
5.3.270.0070.04312.72
5.3.260.0090.03912.72
5.3.250.0130.03412.72
5.3.240.0040.03712.72
5.3.230.0070.03512.70
5.3.220.0030.03912.68
5.3.210.0050.03912.68
5.3.200.0070.03612.68
5.3.190.0020.04212.68
5.3.180.0050.03612.67
5.3.170.0100.03012.67
5.3.160.0040.05212.67
5.3.150.0050.04612.67
5.3.140.0060.03612.66
5.3.130.0050.03812.66
5.3.120.0080.03612.66
5.3.110.0090.03512.66
5.3.100.0050.03912.13
5.3.90.0040.03712.11
5.3.80.0060.03612.10
5.3.70.0050.03612.11
5.3.60.0050.03612.09
5.3.50.0020.04012.04
5.3.40.0040.03712.04
5.3.30.0040.03611.99
5.3.20.0050.03411.77
5.3.10.0070.03811.75
5.3.00.0070.03311.73
5.2.170.0050.0389.23
5.2.160.0080.0439.23
5.2.150.0020.0339.23
5.2.140.0080.0339.22
5.2.130.0080.0289.19
5.2.120.0050.0359.18
5.2.110.0040.0309.19
5.2.100.0090.0359.17
5.2.90.0010.0349.18
5.2.80.0040.0309.18
5.2.70.0080.0269.17
5.2.60.0030.0319.13
5.2.50.0060.0289.10
5.2.40.0050.0309.08
5.2.30.0070.0329.05
5.2.20.0070.0269.04
5.2.10.0040.0278.95
5.2.00.0060.0318.80
5.1.60.0040.0238.10
5.1.50.0070.0278.09
5.1.40.0020.0258.08
5.1.30.0060.0338.41
5.1.20.0040.0388.44
5.1.10.0040.0328.16
5.1.00.0060.0308.17
5.0.50.0040.0226.65
5.0.40.0000.0226.50
5.0.30.0050.0356.32
5.0.20.0040.0246.28
5.0.10.0040.0256.26
5.0.00.0060.0436.25
4.4.90.0040.0224.78
4.4.80.0010.0174.75
4.4.70.0000.0194.76
4.4.60.0030.0174.75
4.4.50.0040.0164.77
4.4.40.0030.0284.71
4.4.30.0010.0174.76
4.4.20.0040.0144.84
4.4.10.0020.0164.85
4.4.00.0030.0244.76
4.3.110.0040.0144.67
4.3.100.0030.0144.66
4.3.90.0020.0154.64
4.3.80.0060.0204.58
4.3.70.0010.0164.63
4.3.60.0040.0134.63
4.3.50.0020.0174.63
4.3.40.0020.0244.54
4.3.30.0050.0133.30
4.3.20.0010.0163.28
4.3.10.0050.0233.23
4.3.00.0270.01713.42

preferences:
63.01 ms | 401 KiB | 5 Q