3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class TypedArray extends ArrayIterator { private $class; public function __construct($class) { $this->class = $class; parent::__construct(array()); } public function offsetSet($index, $newValue) { if (!$newValue instanceof $this->class) { throw new \InvalidArgumentException('Expected instance of ' . $this->class . ' got ' . get_class($newValue)); } } } class A {} $array = new TypedArray(A::class); $array[] = new A; $array['boo'] = new A; foreach ($array as $key => $value) { echo $key . ' -> '; var_dump($value); echo PHP_EOL; } $array[] = 'blah'; /* implements Iterator, ArrayAccess { private $class; private $array; public function __construct($class) { $this->class = $class; $this->array = array(); } public function current() { return current($this->array); } public function key() { return key($this->array); } public function next() { return next($this->array); } public function rewind() { return rewind($this->array); } } */

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.0070.01118.79
8.3.30.0040.01118.91
8.3.20.0040.00420.37
8.3.10.0040.00420.70
8.3.00.0060.00321.95
8.2.170.0110.00722.96
8.2.160.0040.01122.02
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0050.00320.79
8.2.120.0000.00826.35
8.2.110.0060.00320.52
8.2.100.0060.00618.16
8.2.90.0000.00819.35
8.2.80.0040.00417.97
8.2.70.0070.00317.75
8.2.60.0030.00518.04
8.2.50.0080.00018.09
8.2.40.0080.00020.57
8.2.30.0040.00419.52
8.2.20.0000.00717.80
8.2.10.0070.00018.14
8.2.00.0030.00518.00
8.1.270.0130.00322.04
8.1.260.0050.00228.09
8.1.250.0080.00028.09
8.1.240.0090.00022.18
8.1.230.0070.00417.83
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0100.00017.35
8.1.190.0050.00317.35
8.1.180.0000.00818.10
8.1.170.0060.00318.50
8.1.160.0020.00520.81
8.1.150.0050.00218.93
8.1.140.0030.00519.46
8.1.130.0030.00317.74
8.1.120.0000.00717.50
8.1.110.0000.00817.39
8.1.100.0050.00217.45
8.1.90.0000.00717.47
8.1.80.0030.00317.45
8.1.70.0040.00417.52
8.1.60.0040.00417.48
8.1.50.0040.00417.50
8.1.40.0030.00517.57
8.1.30.0030.00617.60
8.1.20.0050.00217.63
8.1.10.0000.00717.63
8.1.00.0030.00717.41
8.0.300.0040.00418.77
8.0.290.0000.00816.75
8.0.280.0040.00418.56
8.0.270.0030.00317.18
8.0.260.0000.00617.27
8.0.250.0040.00416.96
8.0.240.0030.00317.03
8.0.230.0040.00417.01
8.0.220.0000.00716.97
8.0.210.0030.00616.95
8.0.200.0040.00417.03
8.0.190.0000.00817.02
8.0.180.0050.00317.03
8.0.170.0050.00317.04
8.0.160.0050.00216.85
8.0.150.0000.00817.02
8.0.140.0000.00716.90
8.0.130.0000.00713.32
8.0.120.0040.00416.83
8.0.110.0040.00416.97
8.0.100.0040.00416.87
8.0.90.0070.00017.00
8.0.80.0040.01217.01
8.0.70.0000.00717.00
8.0.60.0000.00817.02
8.0.50.0030.00517.02
8.0.30.0080.01117.10
8.0.20.0130.00817.40
8.0.10.0000.00716.93
8.0.00.0080.01016.90
7.4.330.0060.00016.73
7.4.320.0000.00616.41
7.4.300.0060.00016.60
7.4.290.0040.00416.61
7.4.280.0040.00416.41
7.4.270.0000.00716.37
7.4.260.0000.00716.48
7.4.250.0040.00416.49
7.4.240.0040.00416.59
7.4.230.0080.00016.25
7.4.220.0060.01216.54
7.4.210.0070.00716.71
7.4.200.0000.00716.48
7.4.160.0130.00316.59
7.4.150.0110.00717.40
7.4.140.0080.01217.86
7.4.130.0120.00616.60
7.4.120.0060.01116.56
7.4.110.0100.00716.57
7.4.100.0140.01116.52
7.4.90.0090.00916.59
7.4.80.0140.00419.39
7.4.70.0130.01016.56
7.4.60.0030.01316.45
7.4.50.0060.00516.70
7.4.40.0120.00416.45
7.4.30.0130.00316.64
7.4.00.0070.00715.06
7.3.330.0030.00313.44
7.3.320.0000.00613.38
7.3.310.0030.00316.43
7.3.300.0070.00016.33
7.3.290.0070.01016.39
7.3.280.0070.01016.45
7.3.270.0040.01517.40
7.3.260.0120.00616.66
7.3.250.0090.01016.46
7.3.240.0120.00816.47
7.3.230.0110.00716.58
7.3.210.0040.01216.34
7.3.200.0070.01016.54
7.3.190.0030.01316.41
7.3.180.0100.01316.45
7.3.170.0100.01016.45
7.3.160.0090.00616.65
7.3.10.0090.00916.32
7.3.00.0170.00016.41
7.2.330.0070.01116.45
7.2.320.0030.01416.47
7.2.310.0080.00816.83
7.2.300.0090.00916.82
7.2.290.0040.01416.67
7.2.130.0090.00916.42
7.2.120.0120.00316.66
7.2.110.0080.00816.61
7.2.100.0070.00416.35
7.2.90.0040.00816.66
7.2.80.0000.01316.68
7.2.70.0110.00716.85
7.2.60.0110.00516.96
7.2.50.0130.01016.66
7.2.40.0100.00716.83
7.2.30.0060.00916.55
7.2.20.0080.00417.08
7.2.10.0120.00416.51
7.2.00.0050.01118.16
7.1.250.0050.00515.41
7.1.200.0000.01515.96
7.1.100.0100.00318.27
7.1.70.0120.00817.14
7.1.60.0060.01619.40
7.1.50.0030.01017.04
7.1.00.0070.07322.41
7.0.200.0470.01014.64
7.0.60.0130.05721.73
7.0.50.0170.06017.91
7.0.40.0030.04320.24
7.0.30.0300.07320.29
7.0.20.0400.07020.13
7.0.10.0100.08320.23
7.0.00.0030.08720.20
5.6.280.0030.03320.87
5.6.210.0030.06720.48
5.6.200.0100.08018.29
5.6.190.0000.04720.55
5.6.180.0270.05320.39
5.6.170.0270.08020.74
5.6.160.0070.04720.56
5.6.150.0000.04318.12
5.6.140.0070.06718.18
5.6.130.0100.08018.14
5.6.120.0030.06321.16
5.6.110.0070.08321.14
5.6.100.0000.09721.01
5.6.90.0100.07321.04
5.6.80.0000.04320.40
5.5.350.2430.03020.43
5.5.340.0130.06318.08
5.5.330.0030.05020.35
5.5.320.0600.06320.41
5.5.310.0270.04720.30
5.5.300.0070.08018.04
5.5.290.0070.06018.09
5.5.280.0130.05720.81
5.5.270.0130.04020.98
5.5.260.0030.05720.78
5.5.250.0000.06020.55
5.5.240.0070.05720.17

preferences:
44.17 ms | 400 KiB | 5 Q