3v4l.org

run code in 300+ PHP versions simultaneously
<?php class GenericCollection { private $className; private $items = []; public function __construct($className) { if (!class_exists($className)) { throw new \LogicException('Invalid class name: ' . $className); } $this->className = $className; } 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 {} class Bar {} $col = new GenericCollection(Foo::class); $col->push(new Foo); // works $col->push(new Bar); // exception

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.40.0120.00318.96
8.3.30.0150.00719.23
8.3.20.0080.00020.01
8.3.10.0000.00723.48
8.3.00.0080.00019.38
8.2.170.0070.00722.96
8.2.160.0100.00720.52
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0040.01126.16
8.2.120.0040.00421.00
8.2.110.0060.00320.35
8.2.100.0060.00617.91
8.2.90.0000.00817.63
8.2.80.0030.00618.92
8.2.70.0090.00017.63
8.2.60.0000.00817.62
8.2.50.0000.00917.74
8.2.40.0030.00617.75
8.2.30.0000.00917.74
8.2.20.0050.00217.63
8.2.10.0040.00418.08
8.2.00.0040.00417.71
8.1.270.0040.00423.81
8.1.260.0030.00626.35
8.1.250.0030.01028.09
8.1.240.0120.00022.10
8.1.230.0040.00820.98
8.1.220.0040.00417.79
8.1.210.0000.00818.77
8.1.200.0060.00317.38
8.1.190.0040.00417.22
8.1.180.0080.00018.10
8.1.170.0050.00217.62
8.1.160.0000.00818.82
8.1.150.0020.00518.91
8.1.140.0030.00617.46
8.1.130.0030.00317.81
8.1.120.0000.00717.50
8.1.110.0040.00417.46
8.1.100.0040.00417.52
8.1.90.0000.00717.42
8.1.80.0040.00417.46
8.1.70.0000.00717.46
8.1.60.0040.00417.59
8.1.50.0050.00317.61
8.1.40.0040.00417.57
8.1.30.0040.00417.63
8.1.20.0040.00417.71
8.1.10.0000.00817.56
8.1.00.0030.00617.57
8.0.300.0000.00718.77
8.0.290.0040.00416.63
8.0.280.0040.00418.01
8.0.270.0040.00418.09
8.0.260.0040.00417.39
8.0.250.0030.00317.03
8.0.240.0000.00717.03
8.0.230.0000.00817.04
8.0.220.0000.00716.93
8.0.210.0030.00317.03
8.0.200.0060.00017.03
8.0.190.0050.00316.95
8.0.180.0040.00417.03
8.0.170.0040.00416.91
8.0.160.0000.00716.85
8.0.150.0000.00816.84
8.0.140.0050.00316.98
8.0.130.0000.00613.38
8.0.120.0000.00916.82
8.0.110.0070.00016.99
8.0.100.0040.00416.86
8.0.90.0030.00317.04
8.0.80.0060.00917.00
8.0.70.0040.00416.93
8.0.60.0070.00017.02
8.0.50.0050.00216.86
8.0.30.0130.00917.27
8.0.20.0120.00817.40
8.0.10.0040.00417.06
8.0.00.0110.00716.81
7.4.330.0000.00615.09
7.4.320.0060.00016.61
7.4.300.0000.00616.52
7.4.290.0000.00716.50
7.4.280.0030.00516.51
7.4.270.0000.00816.63
7.4.260.0000.00816.40
7.4.250.0030.00516.59
7.4.240.0030.00416.51
7.4.230.0000.00716.52
7.4.220.0100.01216.55
7.4.210.0140.00416.58
7.4.200.0000.00716.73
7.4.160.0070.00716.65
7.4.150.0110.00717.40
7.4.140.0090.00917.86
7.4.130.0130.00316.45
7.4.120.0050.01416.60
7.4.110.0060.01416.48
7.4.100.0100.00616.53
7.4.90.0030.01416.46
7.4.80.0060.01219.39
7.4.70.0130.00916.30
7.4.60.0040.01416.54
7.4.50.0050.00016.67
7.4.40.0050.01116.56
7.4.30.0060.00916.61
7.4.10.0100.00715.16
7.4.00.0030.01315.01
7.3.330.0000.00513.31
7.3.320.0000.00513.41
7.3.310.0030.00316.31
7.3.300.0030.00316.32
7.3.290.0080.00616.37
7.3.280.0060.01116.46
7.3.270.0030.01317.40
7.3.260.0130.00716.50
7.3.250.0120.00716.75
7.3.240.0130.00316.63
7.3.230.0100.00716.40
7.3.210.0060.01216.37
7.3.200.0080.00919.39
7.3.190.0120.00616.58
7.3.180.0070.01016.52
7.3.170.0090.01516.60
7.3.160.0060.00916.57
7.3.130.0100.00714.89
7.3.120.0140.00314.96
7.3.110.0070.01115.03
7.3.100.0070.00714.91
7.3.90.0060.00614.82
7.3.80.0070.00714.92
7.3.70.0060.00314.69
7.3.60.0000.01414.91
7.3.50.0000.01214.98
7.3.40.0060.00914.79
7.3.30.0100.00714.74
7.3.20.0060.00616.84
7.3.10.0090.00616.41
7.3.00.0090.00616.65
7.2.330.0070.01116.67
7.2.320.0030.01316.94
7.2.310.0100.00716.80
7.2.300.0070.01116.75
7.2.290.0080.00816.46
7.2.260.0120.00614.95
7.2.250.0030.01315.14
7.2.240.0040.01215.30
7.2.230.0150.00014.95
7.2.220.0090.00614.98
7.2.210.0110.00714.69
7.2.200.0060.00315.27
7.2.190.0090.00614.99
7.2.180.0070.00715.13
7.2.170.0070.01015.10
7.2.160.0100.00615.30
7.2.150.0040.00816.75
7.2.140.0070.01016.97
7.2.130.0120.00516.96
7.2.120.0100.00016.69
7.2.110.0100.00716.76
7.2.100.0080.00716.77
7.2.90.0070.00716.89
7.2.80.0060.00916.42
7.2.70.0030.00816.96
7.2.60.0090.00616.63
7.2.50.0070.01116.74
7.2.40.0060.01016.81
7.2.30.0140.00316.68
7.2.20.0060.00816.70
7.2.10.0140.00516.88
7.2.00.0040.00917.49
7.1.330.0040.01115.72
7.1.320.0060.01215.98
7.1.310.0040.00415.76
7.1.300.0060.01016.00
7.1.290.0090.00615.85
7.1.280.0030.01015.76
7.1.270.0040.00715.60
7.1.260.0030.00715.94
7.1.250.0140.00015.45
7.1.240.0070.00716.00
7.1.230.0060.00915.77
7.1.220.0070.01015.70
7.1.210.0030.00915.95
7.1.200.0030.01015.89
7.1.190.0050.00515.86
7.1.180.0040.00815.70
7.1.170.0130.00315.73
7.1.160.0120.00415.55
7.1.150.0000.01215.61
7.1.140.0050.00915.60
7.1.130.0000.00915.81
7.1.120.0060.00915.83
7.1.110.0040.00715.94
7.1.100.0060.01117.02
7.1.90.0000.01115.79
7.1.80.0090.00615.86
7.1.70.0060.00516.48
7.1.60.0060.01317.64
7.1.50.0060.00916.28
7.1.40.0040.01115.63
7.1.30.0100.00315.70
7.1.20.0070.00315.63
7.1.10.0090.00315.87
7.1.00.0070.03819.12
7.0.330.0070.00315.32
7.0.320.0050.00515.43
7.0.310.0060.00315.50
7.0.300.0070.01015.46
7.0.290.0070.00415.50
7.0.280.0000.01415.24
7.0.270.0030.00715.34
7.0.260.0040.00715.45
7.0.250.0040.00415.36
7.0.240.0030.01015.50
7.0.230.0100.00015.30
7.0.220.0030.01315.48
7.0.210.0000.01415.47
7.0.200.0140.01016.20
7.0.190.0040.00815.53
7.0.180.0060.00915.59
7.0.170.0030.01015.11
7.0.160.0050.00515.22
7.0.150.0000.01315.57
7.0.140.0080.03718.74
7.0.130.0040.01115.07
7.0.120.0120.00015.54
7.0.110.0040.03017.73
7.0.100.0050.04517.79
7.0.90.0040.04017.74
7.0.80.0020.04617.62
7.0.70.0090.03517.73
7.0.60.0100.04217.61
7.0.50.0060.04117.75
7.0.40.0030.04816.75
7.0.30.0100.04216.63
7.0.20.0070.02816.62
7.0.10.0030.04216.65
7.0.00.0060.04416.63
5.6.400.0070.00714.73
5.6.390.0110.00414.72
5.6.380.0100.00714.34
5.6.370.0000.01414.50
5.6.360.0000.01614.48
5.6.350.0070.00714.33
5.6.340.0000.01414.39
5.6.330.0000.00814.58
5.6.320.0000.01314.58
5.6.310.0040.00814.74
5.6.300.0080.00414.74
5.6.290.0060.00914.63
5.6.280.0060.04017.89
5.6.270.0030.01014.67
5.6.260.0050.04317.51
5.6.250.0100.03617.57
5.6.240.0050.04217.55
5.6.230.0050.04817.61
5.6.220.0100.04017.40
5.6.210.0030.03217.41
5.6.200.0050.02917.45
5.6.190.0050.03817.51
5.6.180.0080.04317.72
5.6.170.0050.04117.38
5.6.160.0070.04217.52
5.6.150.0100.04117.57
5.6.140.0080.04517.53
5.6.130.0050.04417.46
5.6.120.0050.04317.44
5.6.110.0050.03917.49
5.6.100.0040.04417.49
5.6.90.0070.03717.56
5.6.80.0050.02817.28
5.6.70.0100.03917.04
5.6.60.0070.02317.16
5.6.50.0000.03417.24
5.6.40.0030.04517.13
5.6.30.0030.04817.21
5.6.20.0000.02917.18
5.6.10.0080.04117.11
5.6.00.0110.03517.24
5.5.380.0120.04017.46
5.5.370.0030.04517.35
5.5.360.0110.04217.33
5.5.350.0050.04417.46
5.5.340.0050.04217.75
5.5.330.0090.04317.71
5.5.320.0030.04317.66
5.5.310.0070.04817.76
5.5.300.0070.04017.71
5.5.290.0100.03817.55
5.5.280.0050.04217.63
5.5.270.0070.04017.69
5.5.260.0050.04317.56
5.5.250.0090.04217.42
5.5.240.0050.04517.31
5.5.230.0120.04017.33
5.5.220.0070.04117.30
5.5.210.0060.02817.24
5.5.200.0080.04017.30
5.5.190.0050.03517.39
5.5.180.0050.04717.32
5.5.170.0120.00314.35
5.5.160.0070.02717.18
5.5.150.0040.04117.17
5.5.140.0100.03717.32
5.5.130.0110.04017.31
5.5.120.0050.02717.38
5.5.110.0070.03517.25
5.5.100.0070.04017.18
5.5.90.0050.03717.22
5.5.80.0050.03517.09
5.5.70.0100.03317.24
5.5.60.0050.04517.18
5.5.50.0090.04117.03
5.5.40.0050.03017.29
5.5.30.0050.04017.09
5.5.20.0100.03717.17
5.5.10.0080.03516.97
5.5.00.0090.04117.19
5.4.450.0050.04415.34
5.4.440.0120.03515.42
5.4.430.0080.03715.33
5.4.420.0070.04015.34
5.4.410.0050.03515.36
5.4.400.0100.03315.17
5.4.390.0050.04315.17
5.4.380.0050.04115.17
5.4.370.0050.03715.17
5.4.360.0030.03815.21
5.4.350.0080.03815.17
5.4.340.0050.04015.14
5.4.330.0050.00311.33
5.4.320.0030.03715.17
5.4.310.0070.03015.17
5.4.300.0070.03615.33
5.4.290.0070.04015.15
5.4.280.0070.04115.28
5.4.270.0050.04015.32
5.4.260.0030.02815.17
5.4.250.0050.04215.24
5.4.240.0070.02715.19
5.4.230.0050.04215.32
5.4.220.0090.03715.24
5.4.210.0050.03815.17
5.4.200.0030.04215.32
5.4.190.0040.03715.23
5.4.180.0070.03615.25
5.4.170.0020.04515.16
5.4.160.0080.03715.31
5.4.150.0030.04115.13
5.4.140.0070.03513.95
5.4.130.0060.03513.83
5.4.120.0050.04013.93
5.4.110.0070.03513.97
5.4.100.0060.03213.92
5.4.90.0070.03513.82
5.4.80.0070.03513.90
5.4.70.0080.03513.94
5.4.60.0050.03813.81
5.4.50.0020.03913.89
5.4.40.0060.03113.96
5.4.30.0080.03713.91
5.4.20.0070.03913.90
5.4.10.0050.04013.86
5.4.00.0070.02913.64
5.3.290.0030.08014.68
5.3.280.0000.08014.62
5.3.270.0030.07714.62
5.3.260.0030.07714.63
5.3.250.0170.06714.74
5.3.240.0030.08014.73
5.3.230.0070.08014.61
5.3.220.0000.05014.66
5.3.210.0070.07714.54
5.3.200.0130.06714.65
5.3.190.0070.06714.59
5.3.180.0030.04014.68
5.3.170.0130.03714.64
5.3.160.0000.08014.52
5.3.150.0100.07314.57
5.3.140.0070.08014.64
5.3.130.0070.07014.50
5.3.120.0100.07314.55
5.3.110.0030.07714.63
5.3.100.0100.07714.05
5.3.90.0130.06714.14
5.3.80.0100.07313.87
5.3.70.0070.05014.14
5.3.60.0030.07313.85
5.3.50.0130.06314.04
5.3.40.0000.08314.02
5.3.30.0000.07714.14
5.3.20.0170.06013.68
5.3.10.0070.07013.66
5.3.00.0070.07013.78
5.2.170.0100.06011.76
5.2.160.0000.05011.76
5.2.150.0100.06011.76
5.2.140.0100.04311.76
5.2.130.0030.03711.76
5.2.120.0100.06011.76
5.2.110.0070.06011.76
5.2.100.0070.06011.76
5.2.90.0070.06011.76
5.2.80.0030.06311.76
5.2.70.0070.05711.76
5.2.60.0070.05711.76
5.2.50.0100.06011.76
5.2.40.0070.05311.76
5.2.30.0030.06311.76
5.2.20.0070.06011.76
5.2.10.0100.05711.76
5.2.00.0030.06011.76
5.1.60.0100.04711.76
5.1.50.0030.05311.76
5.1.40.0030.05311.76
5.1.30.0030.06011.76
5.1.20.0130.04711.76
5.1.10.0000.05711.76
5.1.00.0030.05311.76
5.0.50.0000.02711.76
5.0.40.0030.04311.76
5.0.30.0070.06311.76
5.0.20.0030.04711.76
5.0.10.0100.02311.76
5.0.00.0070.05711.76
4.4.90.0030.03311.76
4.4.80.0000.02311.76
4.4.70.0030.02311.76
4.4.60.0030.03711.76
4.4.50.0000.02711.76
4.4.40.0100.04711.76
4.4.30.0030.03311.76
4.4.20.0070.03011.76
4.4.10.0030.03311.76
4.4.00.0000.05711.76
4.3.110.0030.03311.76
4.3.100.0030.03311.76
4.3.90.0070.03011.76
4.3.80.0000.04011.76
4.3.70.0030.02711.76
4.3.60.0000.03311.76
4.3.50.0000.03711.76
4.3.40.0030.04011.76
4.3.30.0030.03311.76
4.3.20.0030.03711.76
4.3.10.0000.03311.76
4.3.00.0030.02011.76

preferences:
44.86 ms | 400 KiB | 5 Q