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; $col[18] = 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.0180.00418.55
8.3.50.0170.00322.90
8.3.40.0120.00318.59
8.3.30.0180.00318.95
8.3.20.0070.00020.34
8.3.10.0030.00523.61
8.3.00.0090.00019.25
8.2.180.0070.01118.04
8.2.170.0090.00622.96
8.2.160.0100.00320.14
8.2.150.0070.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00421.00
8.2.110.0070.00320.94
8.2.100.0040.00818.09
8.2.90.0080.00019.09
8.2.80.0000.00817.97
8.2.70.0030.00517.38
8.2.60.0000.00817.68
8.2.50.0040.00418.07
8.2.40.0000.00819.87
8.2.30.0020.01017.96
8.2.20.0070.00017.50
8.2.10.0000.00717.88
8.2.00.0000.00717.56
8.1.280.0070.01325.92
8.1.270.0000.00823.75
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0060.00323.87
8.1.230.0080.00419.54
8.1.220.0050.00317.74
8.1.210.0030.00618.77
8.1.200.0000.01117.10
8.1.190.0060.00316.98
8.1.180.0040.00418.10
8.1.170.0040.00418.34
8.1.160.0040.00422.02
8.1.150.0040.00418.70
8.1.140.0040.00417.29
8.1.130.0000.00717.83
8.1.120.0040.00417.35
8.1.110.0040.00417.36
8.1.100.0000.00817.32
8.1.90.0040.00417.35
8.1.80.0000.00717.44
8.1.70.0000.00817.30
8.1.60.0040.00417.55
8.1.50.0040.00417.44
8.1.40.0030.00517.45
8.1.30.0040.00417.58
8.1.20.0040.00417.45
8.1.10.0040.00417.37
8.1.00.0040.00417.36
8.0.300.0040.00418.77
8.0.290.0040.00416.59
8.0.280.0030.00318.35
8.0.270.0030.00317.16
8.0.260.0030.00317.11
8.0.250.0030.00316.82
8.0.240.0080.00016.91
8.0.230.0000.00716.81
8.0.220.0030.00316.75
8.0.210.0030.00316.90
8.0.200.0000.00716.91
8.0.190.0060.00316.79
8.0.180.0040.00416.94
8.0.170.0000.00816.95
8.0.160.0070.00016.82
8.0.150.0070.00016.71
8.0.140.0040.00416.88
8.0.130.0000.00513.25
8.0.120.0050.00316.83
8.0.110.0000.00816.78
8.0.100.0040.00416.76
8.0.90.0040.00416.99
8.0.80.0100.00716.92
8.0.70.0000.00716.68
8.0.60.0040.00416.72
8.0.50.0000.00716.68
8.0.30.0100.01016.86
8.0.20.0120.00717.40
8.0.10.0070.00016.94
8.0.00.0120.00416.71
7.4.330.0000.00515.03
7.4.320.0000.00616.66
7.4.300.0030.00316.53
7.4.290.0070.00016.66
7.4.280.0000.00716.68
7.4.270.0000.00716.59
7.4.260.0000.00816.63
7.4.250.0040.00416.52
7.4.240.0050.00216.58
7.4.230.0040.00416.66
7.4.220.0180.00916.57
7.4.210.0030.01316.66
7.4.200.0000.00716.62
7.4.160.0100.00616.45
7.4.150.0070.01117.40
7.4.140.0090.00817.86
7.4.130.0110.00616.54
7.4.120.0110.00616.58
7.4.110.0060.01116.52
7.4.100.0060.01216.48
7.4.90.0080.00816.57
7.4.80.0070.01819.39
7.4.70.0100.00616.62
7.4.60.0080.00816.46
7.4.50.0000.00616.54
7.4.40.0060.00916.56
7.4.30.0100.00516.42
7.4.00.0080.00814.94
7.3.330.0030.00313.30
7.3.320.0030.00313.43
7.3.310.0070.00016.52
7.3.300.0000.00716.34
7.3.290.0070.01116.50
7.3.280.0100.00616.50
7.3.270.0030.01717.40
7.3.260.0120.01116.46
7.3.250.0100.00716.64
7.3.240.0080.00816.42
7.3.230.0080.00816.47
7.3.210.0060.01016.45
7.3.200.0080.00819.39
7.3.190.0000.01716.40
7.3.180.0110.01116.64
7.3.170.0000.01916.41
7.3.160.0100.00716.74
7.2.330.0100.01316.96
7.2.320.0070.01016.93
7.2.310.0030.01416.50
7.2.300.0110.00816.55
7.2.290.0040.01216.53
7.2.60.0110.00716.80
7.1.200.0040.00815.64
7.1.100.0060.00618.31
7.1.70.0180.00416.67
7.1.60.0120.01219.40
7.1.50.0080.01216.55
7.1.00.0000.08022.57
7.0.200.0270.00616.52
7.0.140.0030.07722.09
7.0.60.0000.04720.05
7.0.50.0030.04317.88
7.0.40.0000.04720.40
7.0.30.0230.03320.34
7.0.20.0470.06720.17
7.0.10.0070.08720.20
7.0.00.0070.09020.32
5.6.280.0030.07321.09
5.6.210.0000.08720.79
5.6.200.0070.05018.25
5.6.190.0130.08020.45
5.6.180.3670.04320.33
5.6.170.0200.06720.55
5.6.160.0130.07720.41
5.6.150.0030.08718.29
5.6.140.0100.08018.17
5.6.130.0100.03718.18
5.6.120.0030.06021.14
5.6.110.0100.07721.00
5.6.100.0070.08321.06
5.6.90.0130.07721.05
5.6.80.0100.04320.40
5.6.70.3730.04320.40
5.5.350.0170.06720.49
5.5.340.0130.07318.07
5.5.330.0000.08720.28
5.5.320.0530.06320.35
5.5.310.0270.05320.28
5.5.300.0070.05318.04
5.5.290.0100.08017.95
5.5.280.0030.08720.82
5.5.270.0000.05020.90
5.5.260.0070.04020.76
5.5.250.0100.06320.68
5.5.240.0270.06720.09
5.4.450.0300.05319.20
5.4.440.0500.04319.32
5.4.430.0430.03719.16
5.4.420.0430.04719.16
5.4.410.0500.04019.41
5.4.400.0100.04019.11
5.4.390.0400.04019.11
5.4.380.0130.05718.62
5.4.370.0100.05718.55
5.4.360.0130.06018.70
5.4.350.0200.04718.69
5.4.340.0300.06018.77
5.4.320.0100.04212.54
5.4.310.0040.04012.54
5.4.300.0050.03712.54
5.4.290.0040.03812.54
5.4.280.0030.03712.43
5.4.270.0040.04012.43
5.4.260.0050.03812.43
5.4.250.0040.03912.43
5.4.240.0060.03512.43
5.4.230.0050.03912.42
5.4.220.0060.03512.42
5.4.210.0040.03712.42
5.4.200.0080.03512.42
5.4.190.0050.03912.41
5.4.180.0030.04012.42
5.4.170.0060.03912.42
5.4.160.0080.03212.41
5.4.150.0050.03612.41
5.4.140.0050.03812.10
5.4.130.0040.04312.09
5.4.120.0080.04212.05
5.4.110.0020.04012.04
5.4.100.0040.04012.04
5.4.90.0040.04812.05
5.4.80.0070.03612.05
5.4.70.0060.03412.04
5.4.60.0060.04212.04
5.4.50.0020.03712.04
5.4.40.0090.04212.03
5.4.30.0050.03512.03
5.4.20.0040.03512.02
5.4.10.0030.03512.03
5.4.00.0070.03311.52
5.3.290.0050.04712.80
5.3.280.0060.04112.71
5.3.270.0080.04012.73
5.3.260.0080.03712.72
5.3.250.0050.04212.72
5.3.240.0050.04312.72
5.3.230.0030.04612.71
5.3.220.0030.03812.68
5.3.210.0030.04812.68
5.3.200.0070.03512.68
5.3.190.0040.04112.68
5.3.180.0050.03612.68
5.3.170.0040.04812.66
5.3.160.0030.04412.68
5.3.150.0060.05012.68
5.3.140.0060.04412.66
5.3.130.0060.04212.66
5.3.120.0020.04012.66
5.3.110.0080.03512.66
5.3.100.0040.03712.14
5.3.90.0090.03212.12
5.3.80.0030.03812.11
5.3.70.0070.04912.10
5.3.60.0060.04312.09
5.3.50.0050.04212.04
5.3.40.0070.03312.04
5.3.30.0070.03311.99
5.3.20.0090.03511.77
5.3.10.0050.03811.74
5.3.00.0040.03611.73
5.2.170.0020.0329.23
5.2.160.0040.0299.23
5.2.150.0090.0309.22
5.2.140.0010.0339.23
5.2.130.0060.0269.18
5.2.120.0040.0289.18
5.2.110.0040.0309.19
5.2.100.0040.0369.18
5.2.90.0070.0339.18
5.2.80.0050.0349.17
5.2.70.0060.0289.18
5.2.60.0050.0299.13
5.2.50.0040.0299.10
5.2.40.0040.0289.07
5.2.30.0050.0289.05
5.2.20.0040.0299.04
5.2.10.0070.0248.95
5.2.00.0030.0298.81
5.1.60.0010.0268.09
5.1.50.0060.0338.09
5.1.40.0060.0288.07
5.1.30.0020.0278.41
5.1.20.0040.0288.45
5.1.10.0040.0278.17
5.1.00.0030.0258.17
5.0.50.0040.0196.64
5.0.40.0060.0166.50
5.0.30.0040.0306.32
5.0.20.0040.0186.28
5.0.10.0010.0226.26
5.0.00.0060.0276.25
4.4.90.0020.0154.78
4.4.80.0020.0154.75
4.4.70.0030.0224.75
4.4.60.0040.0194.75
4.4.50.0000.0174.77
4.4.40.0050.0304.71
4.4.30.0040.0134.76
4.4.20.0040.0194.85
4.4.10.0010.0164.85
4.4.00.0020.0254.76
4.3.110.0040.0134.67
4.3.100.0010.0164.66
4.3.90.0030.0134.64
4.3.80.0040.0234.59
4.3.70.0050.0114.63
4.3.60.0030.0164.63
4.3.50.0030.0154.63
4.3.40.0030.0334.54
4.3.30.0030.0233.30
4.3.20.0020.0213.28
4.3.10.0020.0153.24
4.3.00.0030.01313.42

preferences:
47.75 ms | 401 KiB | 5 Q