3v4l.org

run code in 300+ PHP versions simultaneously
<?php class GenericCollection { private $className; private $items = []; public function __construct($className, $data = []) { if (!class_exists($className)) { throw new \LogicException('Invalid class name: ' . $className); } $this->className = $className; 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 push($item) { $this->checkItemIsInstanceOfCorrectClass($item); array_push($this->items, $item); } public function unshift($item) { $this->checkItemIsInstanceOfCorrectClass($item); array_unshift($this->items, $item); } // other collection methods } class Foo {} $col = new GenericCollection(Foo::class, [new Foo, new 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.0120.00918.40
8.3.50.0100.00522.83
8.3.40.0070.00718.77
8.3.30.0170.00319.07
8.3.20.0070.01120.02
8.3.10.0000.00823.52
8.3.00.0110.00419.24
8.2.180.0070.01416.50
8.2.170.0090.00622.96
8.2.160.0070.00720.43
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0060.00926.16
8.2.120.0070.00020.96
8.2.110.0030.00622.03
8.2.100.0040.00718.22
8.2.90.0000.00819.17
8.2.80.0000.00817.97
8.2.70.0000.00817.63
8.2.60.0090.00017.93
8.2.50.0080.00018.07
8.2.40.0040.00419.88
8.2.30.0090.00319.92
8.2.20.0020.00517.74
8.2.10.0000.00718.01
8.2.00.0070.00017.60
8.1.280.0070.00725.92
8.1.270.0030.00523.91
8.1.260.0070.00326.35
8.1.250.0060.00328.09
8.1.240.0040.00422.23
8.1.230.0080.00319.09
8.1.220.0040.00417.74
8.1.210.0030.00618.77
8.1.200.0120.00017.36
8.1.190.0040.00417.23
8.1.180.0040.00418.10
8.1.170.0040.00418.59
8.1.160.0050.00322.02
8.1.150.0000.00718.94
8.1.140.0040.00417.48
8.1.130.0000.00717.82
8.1.120.0000.00817.52
8.1.110.0030.00517.46
8.1.100.0000.00817.41
8.1.90.0040.00417.48
8.1.80.0070.00017.46
8.1.70.0040.00417.42
8.1.60.0040.00417.61
8.1.50.0040.00417.45
8.1.40.0000.00717.48
8.1.30.0040.00417.55
8.1.20.0050.00217.55
8.1.10.0020.00517.62
8.1.00.0040.00417.52
8.0.300.0020.00518.77
8.0.290.0070.00016.75
8.0.280.0000.00718.37
8.0.270.0040.00417.25
8.0.260.0070.00017.27
8.0.250.0000.00616.99
8.0.240.0040.00416.94
8.0.230.0000.00716.82
8.0.220.0030.00316.90
8.0.210.0070.00016.95
8.0.200.0000.00616.84
8.0.190.0000.00916.85
8.0.180.0030.00316.84
8.0.170.0080.00016.93
8.0.160.0050.00317.01
8.0.150.0040.00416.91
8.0.140.0040.00416.72
8.0.130.0030.00313.39
8.0.120.0040.00416.86
8.0.110.0040.00416.82
8.0.100.0070.00016.81
8.0.90.0050.00216.77
8.0.80.0040.01116.85
8.0.70.0000.00816.90
8.0.60.0070.00016.77
8.0.50.0050.00216.89
8.0.30.0110.00817.09
8.0.20.0080.01117.40
8.0.10.0040.00417.14
8.0.00.0050.01216.86
7.4.330.0000.00515.00
7.4.320.0060.00016.63
7.4.300.0000.00716.48
7.4.290.0030.00316.61
7.4.280.0040.00416.39
7.4.270.0030.00316.60
7.4.260.0070.00016.46
7.4.250.0000.00716.55
7.4.240.0030.00316.48
7.4.230.0030.00316.68
7.4.220.0090.01816.66
7.4.210.0090.00616.55
7.4.200.0040.00416.59
7.4.160.0030.01216.34
7.4.150.0120.00617.40
7.4.140.0140.00317.86
7.4.130.0110.00516.45
7.4.120.0110.00616.58
7.4.110.0140.00316.39
7.4.100.0060.01016.43
7.4.90.0060.01216.36
7.4.80.0070.01419.39
7.4.70.0070.01016.67
7.4.60.0100.00616.48
7.4.50.0030.00316.57
7.4.40.0030.01316.38
7.4.30.0060.00916.46
7.4.00.0030.01015.16
7.3.330.0030.00313.32
7.3.320.0050.00013.38
7.3.310.0000.00816.48
7.3.300.0030.00316.24
7.3.290.0140.00016.31
7.3.280.0050.01316.36
7.3.270.0070.01017.40
7.3.260.0070.01316.39
7.3.250.0090.00916.42
7.3.240.0060.01016.31
7.3.230.0000.01716.57
7.3.210.0110.01416.56
7.3.200.0040.01216.50
7.3.190.0130.01016.41
7.3.180.0070.01016.39
7.3.170.0100.01316.39
7.3.160.0060.00916.47
7.3.10.0120.01016.45
7.3.00.0130.00316.34
7.2.330.0040.01216.73
7.2.320.0040.01916.45
7.2.310.0080.00816.47
7.2.300.0110.00716.82
7.2.290.0090.00616.89
7.2.130.0060.00816.70
7.2.120.0090.00816.76
7.2.110.0080.00916.87
7.2.100.0040.00716.82
7.2.90.0050.00916.86
7.2.80.0080.00717.02
7.2.70.0130.00616.85
7.2.60.0050.00816.87
7.2.50.0090.00616.79
7.2.40.0060.00816.80
7.2.30.0080.00816.81
7.2.20.0110.00716.85
7.2.10.0080.00517.03
7.2.00.0040.01016.91
7.1.250.0090.00715.82
7.1.240.0050.00815.76
7.1.230.0050.00715.63
7.1.220.0060.00615.77
7.1.210.0040.01015.58
7.1.200.0060.00615.65
7.1.190.0070.00715.71
7.1.180.0060.00715.87
7.1.170.0060.01015.74
7.1.160.0080.00715.75
7.1.150.0070.00715.78
7.1.140.0010.01015.70
7.1.130.0070.00415.86
7.1.120.0070.00515.73
7.1.110.0070.00515.91
7.1.100.0100.00615.76
7.1.90.0030.01015.54
7.1.80.0100.00515.80
7.1.70.0090.00316.24
7.1.60.0090.00816.95
7.1.50.0100.00615.95
7.1.40.0060.00515.76
7.1.30.0040.00715.68
7.1.20.0030.00715.67
7.1.10.0000.01015.73
7.1.00.0070.02818.00
7.0.330.0050.00615.07
7.0.320.0080.00315.44
7.0.310.0080.00515.28
7.0.300.0110.00515.29
7.0.290.0070.00515.39
7.0.280.0020.01115.28
7.0.270.0020.00815.35
7.0.260.0020.01115.53
7.0.250.0070.00515.51
7.0.240.0070.00915.45
7.0.230.0060.00515.51
7.0.220.0070.00715.50
7.0.210.0080.00215.32
7.0.200.0130.00715.78
7.0.190.0090.00715.44
7.0.180.0040.01115.41
7.0.170.0000.01015.37
7.0.160.0020.00915.38
7.0.150.0080.00715.40
7.0.140.0040.02817.63
7.0.130.0070.00615.35
7.0.120.0060.00615.29
7.0.110.0090.01015.07
7.0.100.0010.01215.19
7.0.90.0070.00715.26
7.0.80.0060.00715.38
7.0.70.0050.01015.43
7.0.60.0090.01816.89
7.0.50.0080.03116.19
7.0.40.0110.02115.52
7.0.30.0150.02115.72
7.0.20.0160.03015.61
7.0.10.0050.02015.58
7.0.00.0050.03615.66
5.6.380.0060.00914.28
5.6.370.0120.00414.43
5.6.360.0030.01214.29
5.6.350.0050.00714.36
5.6.340.0080.00514.28
5.6.330.0060.00714.33
5.6.320.0100.00514.28
5.6.310.0070.01014.47
5.6.300.0040.00514.40
5.6.290.0050.00714.27
5.6.280.0040.02916.52
5.6.270.0090.00214.38
5.6.260.0110.00314.26
5.6.250.0030.01214.06
5.6.240.0090.00814.31
5.6.230.0050.00814.24
5.6.220.0080.00514.18
5.6.210.0080.02916.55
5.6.200.0070.03415.54
5.6.190.0050.03516.25
5.6.180.1110.01916.27
5.6.170.0120.03216.36
5.6.160.0040.02416.34
5.6.150.0100.02015.70
5.6.140.0110.01715.48
5.6.130.0060.03215.64
5.6.120.0090.02416.59
5.6.110.0060.03216.63
5.6.100.0090.01716.38
5.6.90.0090.02016.45
5.6.80.0050.03216.43
5.6.70.1550.01716.45
5.6.60.0110.00614.51
5.6.50.0040.00813.96
5.6.40.0060.00614.37
5.6.30.0050.00714.22
5.6.20.0080.00514.21
5.6.10.0020.01014.17
5.6.00.0080.00614.34
5.5.380.0050.00611.31
5.5.370.0080.00811.09
5.5.360.0020.01011.06
5.5.350.0080.03014.24
5.5.340.0050.03013.39
5.5.330.0080.02014.28
5.5.320.0210.02814.34
5.5.310.0150.01614.27
5.5.300.0050.03013.45
5.5.290.0070.02713.52
5.5.280.0030.02214.36
5.5.270.0050.02314.27
5.5.260.0040.02414.34
5.5.250.0060.01914.22
5.5.240.0080.01314.09
5.5.230.0050.00411.08
5.5.220.0050.00211.04
5.5.210.0020.00811.16
5.5.200.0030.00611.20
5.5.190.0040.00311.15
5.5.180.0020.00811.12
5.5.170.0030.00811.05
5.5.160.0040.00511.22
5.5.150.0040.00711.14
5.5.140.0020.00710.96
5.5.130.0060.00410.81
5.5.120.0060.00611.26
5.5.110.0020.00911.18
5.5.100.0050.00510.94
5.5.90.0080.00311.15
5.5.80.0080.00311.17
5.5.70.0040.00610.89
5.5.60.0030.00810.85
5.5.50.0020.00511.15
5.5.40.0040.00811.26
5.5.30.0040.00710.90
5.5.20.0080.00311.07
5.5.10.0050.00111.17
5.5.00.0050.00610.83
5.4.450.0160.02013.66
5.4.440.0150.02313.64
5.4.430.0160.01813.67
5.4.420.0180.01913.69
5.4.410.0150.01913.57
5.4.400.0070.01713.65
5.4.390.0120.02113.43
5.4.380.0170.02113.29
5.4.370.0110.02413.46
5.4.360.0190.01813.31
5.4.350.0190.01713.30
5.4.340.0150.02013.28
5.4.330.0070.00210.80
5.4.320.0020.01611.34
5.4.310.0070.01511.31
5.4.300.0030.01811.28
5.4.290.0060.01711.24
5.4.280.0080.01611.39
5.4.270.0030.01811.29
5.4.260.0060.01911.35
5.4.250.0070.01411.27
5.4.240.0050.01611.31
5.4.230.0050.01711.28
5.4.220.0040.02011.31
5.4.210.0040.01611.17
5.4.200.0060.02211.29
5.4.190.0040.01911.35
5.4.180.0040.02111.33
5.4.170.0050.01711.17
5.4.160.0040.01511.25
5.4.150.0050.02011.14
5.4.140.0060.01911.18
5.4.130.0070.01911.16
5.4.120.0080.01711.03
5.4.110.0050.01611.11
5.4.100.0060.01411.08
5.4.90.0040.01911.04
5.4.80.0080.01311.21
5.4.70.0050.01411.09
5.4.60.0060.01611.18
5.4.50.0040.01911.13
5.4.40.0040.02011.08
5.4.30.0070.01711.08
5.4.20.0060.01911.14
5.4.10.0020.02111.12
5.4.00.0040.02011.02
5.3.290.0050.01811.18
5.3.280.0060.01611.05
5.3.270.0070.02011.13
5.3.260.0060.02510.99
5.3.250.0060.02111.01
5.3.240.0060.01511.02
5.3.230.0060.01811.07
5.3.220.0030.01810.94
5.3.210.0100.01911.07
5.3.200.0060.01611.07
5.3.190.0060.01911.00
5.3.180.0050.01911.08
5.3.170.0060.01311.17
5.3.160.0070.01411.17
5.3.150.0040.01611.10
5.3.140.0060.01311.10
5.3.130.0020.01711.08
5.3.120.0030.01611.05
5.3.110.0050.01511.09
5.3.100.0040.01710.89
5.3.90.0040.01711.01
5.3.80.0060.01810.88
5.3.70.0050.01610.93
5.3.60.0050.01510.91
5.3.50.0040.01610.77
5.3.40.0050.01410.86
5.3.30.0040.01610.82
5.3.20.0040.01710.71
5.3.10.0040.01510.63
5.3.00.0050.01410.60
5.2.170.0020.0149.35
5.2.160.0030.0169.30
5.2.150.0030.0169.32
5.2.140.0050.0169.32
5.2.130.0020.0169.30
5.2.120.0050.0139.34
5.2.110.0040.0179.29
5.2.100.0020.0169.31
5.2.90.0020.0159.29
5.2.80.0030.0139.29
5.2.70.0040.0139.29
5.2.60.0020.0149.27
5.2.50.0020.0149.26
5.2.40.0060.0119.27
5.2.30.0070.0109.24
5.2.20.0020.0159.24
5.2.10.0030.0139.21
5.2.00.0050.0139.16
5.1.60.0040.0108.93
5.1.50.0040.0108.92
5.1.40.0040.0108.92
5.1.30.0040.0129.04
5.1.20.0050.0109.04
5.1.10.0010.0128.95
5.1.00.0030.0118.95
5.0.50.0010.0148.44
5.0.40.0040.0118.40
5.0.30.0030.0138.33
5.0.20.0010.0118.32
5.0.10.0030.0098.32
5.0.00.0040.0138.31
4.4.90.0030.0097.82
4.4.80.0040.0077.81
4.4.70.0020.0087.81
4.4.60.0030.0077.81
4.4.50.0030.0087.82
4.4.40.0040.0117.80
4.4.30.0030.0067.82
4.4.20.0020.0077.84
4.4.10.0010.0117.84
4.4.00.0030.0097.82
4.3.110.0050.0077.79
4.3.100.0040.0067.79
4.3.90.0020.0097.77
4.3.80.0020.0127.76
4.3.70.0040.0067.77
4.3.60.0020.0087.77
4.3.50.0020.0097.77
4.3.40.0010.0137.74
4.3.30.0050.0057.33
4.3.20.0020.0077.32
4.3.10.0040.0067.31
4.3.00.0020.00910.70

preferences:
44.87 ms | 401 KiB | 5 Q