3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Collection { /** @var string */ private $type; private $objects = []; /** * @param string $type * @return Collection */ public static function ofType($type) { $collection = new static(); $collection->type = $type; $class = explode('\\', $type); class_alias(self::class, sprintf('%sCollection', array_pop($class))); return $collection; } public function add($object) { if (!$object instanceof $this->type) { throw new Exception(sprintf('Object of type [%s] is not [%s]', get_class($object), $this->type)); } $this->objects[] = $object; } public function getAll() { return $this->objects; } } final class Person {} $col = Collection::ofType(Person::class); $col->add($person); function parsePersonCollection(PersonCollection $coll) { var_dump($coll->getAll()); } parsePersonCollection($col);

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.0080.00818.75
8.3.30.0120.00618.88
8.3.20.0030.00520.38
8.3.10.0080.00023.64
8.3.00.0080.00019.63
8.2.170.0100.00722.96
8.2.160.0100.00322.13
8.2.150.0040.00424.18
8.2.140.0000.00724.66
8.2.130.0030.00619.36
8.2.120.0040.00426.35
8.2.110.0000.01021.11
8.2.100.0080.00317.78
8.2.90.0000.00817.84
8.2.80.0040.00417.97
8.2.70.0090.00317.46
8.2.60.0050.00317.93
8.2.50.0080.00018.07
8.2.40.0000.00819.25
8.2.30.0000.00720.64
8.2.20.0030.00617.82
8.2.10.0030.00518.06
8.2.00.0000.00718.12
8.1.270.0030.00622.23
8.1.260.0000.00728.09
8.1.250.0000.00828.09
8.1.240.0060.00322.52
8.1.230.0090.00320.91
8.1.220.0000.00817.74
8.1.210.0040.00418.82
8.1.200.0050.00517.22
8.1.190.0000.00817.25
8.1.180.0070.00018.10
8.1.170.0030.00620.37
8.1.160.0080.00022.13
8.1.150.0070.00018.82
8.1.140.0000.00819.59
8.1.130.0070.00017.70
8.1.120.0070.00017.52
8.1.110.0040.00417.43
8.1.100.0040.00417.47
8.1.90.0000.00817.54
8.1.80.0040.00417.38
8.1.70.0000.00717.45
8.1.60.0030.00617.61
8.1.50.0080.00017.57
8.1.40.0040.00417.45
8.1.30.0030.00517.59
8.1.20.0000.00817.62
8.1.10.0080.00017.57
8.1.00.0000.00817.57
8.0.300.0040.00419.98
8.0.290.0000.00716.75
8.0.280.0040.00318.52
8.0.270.0040.00417.25
8.0.260.0000.00617.14
8.0.250.0070.00017.01
8.0.240.0040.00417.07
8.0.230.0000.00716.94
8.0.220.0070.00016.86
8.0.210.0050.00316.86
8.0.200.0000.00716.92
8.0.190.0090.00017.01
8.0.180.0000.01017.07
8.0.170.0060.00616.96
8.0.160.0030.00517.07
8.0.150.0050.00216.89
8.0.140.0070.00416.91
8.0.130.0030.00313.41
8.0.120.0000.00816.80
8.0.110.0000.00917.02
8.0.100.0040.00417.00
8.0.90.0050.00217.03
8.0.80.0090.00716.96
8.0.70.0050.00316.92
8.0.60.0040.00417.03
8.0.50.0020.00516.87
8.0.30.0040.01517.00
8.0.20.0130.00717.40
8.0.10.0080.00017.08
8.0.00.0120.00616.92
7.4.330.0000.00516.67
7.4.320.0030.00316.52
7.4.300.0030.00316.51
7.4.290.0040.00416.59
7.4.280.0040.00416.42
7.4.270.0000.00716.53
7.4.260.0070.00016.64
7.4.250.0040.00416.58
7.4.240.0020.00616.49
7.4.230.0070.00016.53
7.4.220.0090.00916.54
7.4.210.0030.01316.54
7.4.200.0050.00216.50
7.4.160.0070.01016.46
7.4.150.0140.00617.40
7.4.140.0070.01217.86
7.4.130.0120.00716.62
7.4.120.0100.00716.54
7.4.110.0120.00616.39
7.4.100.0150.00916.64
7.4.90.0100.00716.72
7.4.80.0190.00019.39
7.4.70.0070.01316.66
7.4.60.0130.00316.52
7.4.50.0030.01416.30
7.4.40.0120.00616.40
7.4.30.0030.01516.48
7.4.00.0070.01115.12
7.3.330.0000.00613.44
7.3.320.0000.00613.31
7.3.310.0030.00316.43
7.3.300.0000.00716.45
7.3.290.0080.00716.41
7.3.280.0070.01016.42
7.3.270.0130.01017.40
7.3.260.0070.01116.43
7.3.250.0090.00916.38
7.3.240.0130.00816.41
7.3.230.0060.01216.46
7.3.210.0030.01316.66
7.3.200.0070.01116.51
7.3.190.0090.00916.64
7.3.180.0130.00316.46
7.3.170.0100.00716.71
7.3.160.0070.01016.47
7.3.120.0110.00514.83
7.3.110.0100.00714.79
7.3.100.0070.00914.67
7.3.90.0030.01314.78
7.3.80.0090.00715.07
7.3.70.0000.01214.87
7.3.60.0080.00514.90
7.3.50.0060.00814.80
7.3.40.0000.00915.04
7.3.30.0090.00714.91
7.3.20.0040.00916.75
7.3.10.0100.00716.75
7.3.00.0060.00816.55
7.2.330.0140.00516.41
7.2.320.0070.01016.78
7.2.310.0100.00616.86
7.2.300.0150.00616.46
7.2.290.0070.01716.80
7.2.250.0100.01015.00
7.2.240.0060.01115.12
7.2.230.0040.01115.00
7.2.220.0060.00915.00
7.2.210.0060.00814.80
7.2.200.0050.00515.14
7.2.190.0030.01015.00
7.2.180.0060.01014.89
7.2.170.0040.01115.04
7.2.160.0060.00615.14
7.2.150.0030.01016.96
7.2.140.0090.00616.93
7.2.130.0030.01616.78
7.2.120.0070.00317.11
7.2.110.0040.01116.85
7.2.100.0060.01016.95
7.2.90.0080.00816.84
7.2.80.0090.00617.09
7.2.70.0110.00416.91
7.2.60.0050.01116.94
7.2.50.0100.01016.68
7.2.40.0070.01416.68
7.2.30.0030.00716.94
7.2.20.0030.00616.91
7.2.10.0000.01817.01
7.2.00.0090.00718.24
7.1.330.0080.00915.81
7.1.320.0070.00515.77
7.1.310.0050.00815.85
7.1.300.0050.00815.83
7.1.290.0060.00315.73
7.1.280.0050.00815.62
7.1.270.0040.01015.67
7.1.260.0060.00815.73
7.1.250.0070.00715.85
7.1.200.0060.00615.80
7.1.100.0070.00718.30
7.1.70.0070.00017.26
7.1.60.0040.01919.48
7.1.50.0110.00716.90
7.1.00.0130.06722.36
7.0.200.0400.00315.00
7.0.60.0100.05720.06
7.0.50.0030.06717.90
7.0.40.0100.08320.30
7.0.30.0230.08720.09
7.0.20.0300.07720.30
7.0.10.0130.08720.10
7.0.00.0130.07320.11
5.6.280.0000.04021.08
5.6.210.0170.04320.60
5.6.200.0070.08018.19
5.6.190.0100.08320.64
5.6.180.0200.06320.57
5.6.170.0300.07020.45
5.6.160.0030.04320.46
5.6.150.0030.04318.15
5.6.140.0030.04318.17
5.6.130.0070.04018.18
5.6.120.0100.03321.02
5.6.110.0130.07020.99
5.6.100.0000.06721.12
5.6.90.0000.04320.89
5.6.80.0000.04020.39
5.5.350.4230.04020.39
5.5.340.0070.07717.99
5.5.330.0000.04320.37
5.5.320.0700.06720.30
5.5.310.0370.05320.37
5.5.300.0270.06017.93
5.5.290.0000.05317.98
5.5.280.0100.08320.86
5.5.270.0100.04320.88
5.5.260.0130.07320.68
5.5.250.0030.07020.72
5.5.240.0330.06020.16

preferences:
48.45 ms | 400 KiB | 5 Q