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); } } } 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.60.0090.01318.68
8.3.50.0100.00821.99
8.3.40.0060.01218.84
8.3.30.0030.01118.92
8.3.20.0070.00020.35
8.3.10.0080.00020.65
8.3.00.0040.00421.60
8.2.180.0110.01116.63
8.2.170.0070.00722.96
8.2.160.0070.00722.12
8.2.150.0030.00624.18
8.2.140.0000.00824.66
8.2.130.0000.00820.85
8.2.120.0040.00426.35
8.2.110.0060.00320.97
8.2.100.0080.00318.34
8.2.90.0030.00619.29
8.2.80.0040.00417.97
8.2.70.0000.00817.63
8.2.60.0040.00817.78
8.2.50.0110.00018.07
8.2.40.0000.00920.07
8.2.30.0000.00818.05
8.2.20.0000.00717.86
8.2.10.0070.00018.00
8.2.00.0000.00818.07
8.1.280.0090.00625.92
8.1.270.0000.01022.18
8.1.260.0000.00828.09
8.1.250.0050.00228.09
8.1.240.0050.00522.73
8.1.230.0080.00417.77
8.1.220.0060.00317.76
8.1.210.0060.00318.77
8.1.200.0000.00917.35
8.1.190.0060.00317.22
8.1.180.0050.00318.10
8.1.170.0000.00818.64
8.1.160.0080.00018.81
8.1.150.0000.00718.87
8.1.140.0080.00019.48
8.1.130.0000.00717.63
8.1.120.0050.00317.46
8.1.110.0000.00817.45
8.1.100.0080.00017.47
8.1.90.0040.00417.45
8.1.80.0050.00317.48
8.1.70.0030.00517.48
8.1.60.0070.00017.50
8.1.50.0030.00617.55
8.1.40.0040.00417.39
8.1.30.0080.00017.63
8.1.20.0020.00517.51
8.1.10.0000.00917.59
8.1.00.0030.00617.54
8.0.300.0030.00518.77
8.0.290.0080.00016.75
8.0.280.0000.00718.45
8.0.270.0070.00017.12
8.0.260.0070.00017.17
8.0.250.0030.00316.89
8.0.240.0000.00716.97
8.0.230.0000.00716.99
8.0.220.0000.00816.91
8.0.210.0030.00616.94
8.0.200.0000.00816.89
8.0.190.0030.00617.00
8.0.180.0040.00416.95
8.0.170.0040.00416.97
8.0.160.0030.00316.96
8.0.150.0040.00416.80
8.0.140.0000.00716.91
8.0.130.0030.00313.36
8.0.120.0040.00416.96
8.0.110.0030.00516.84
8.0.100.0050.00216.81
8.0.90.0040.00416.93
8.0.80.0100.00616.89
8.0.70.0030.00616.73
8.0.60.0000.00716.79
8.0.50.0070.00016.97
8.0.30.0120.00517.08
8.0.20.0110.00717.40
8.0.10.0050.00317.13
8.0.00.0110.00716.85
7.4.330.0000.00516.76
7.4.320.0070.00016.52
7.4.300.0060.00016.39
7.4.290.0050.00516.57
7.4.280.0000.00816.58
7.4.270.0000.00716.53
7.4.260.0040.00416.37
7.4.250.0070.00016.61
7.4.240.0000.00716.40
7.4.230.0000.00716.57
7.4.220.0090.00916.53
7.4.210.0120.00316.39
7.4.200.0050.00216.50
7.4.160.0120.00316.36
7.4.150.0110.00717.40
7.4.140.0120.00817.86
7.4.130.0090.00916.55
7.4.120.0080.00816.52
7.4.110.0120.00916.69
7.4.100.0110.01116.68
7.4.90.0000.01716.56
7.4.80.0110.00719.39
7.4.70.0080.00916.72
7.4.60.0090.00916.56
7.4.50.0070.00716.40
7.4.40.0090.00616.50
7.4.30.0150.00316.39
7.4.00.0040.01115.20
7.3.330.0000.00613.42
7.3.320.0000.00513.37
7.3.310.0030.00316.41
7.3.300.0000.00716.33
7.3.290.0120.00616.41
7.3.280.0080.01016.38
7.3.270.0160.00617.40
7.3.260.0170.01416.45
7.3.250.0120.00516.57
7.3.240.0060.01216.56
7.3.230.0130.00316.42
7.3.210.0040.01316.53
7.3.200.0060.01216.49
7.3.190.0120.00616.54
7.3.180.0160.00616.34
7.3.170.0090.00816.50
7.3.160.0090.00616.38
7.3.00.0050.00316.65
7.2.330.0180.00316.70
7.2.320.0090.00916.72
7.2.310.0100.00716.75
7.2.300.0140.00316.66
7.2.290.0080.00816.73
7.2.130.0070.00716.71
7.2.120.0050.00516.89
7.2.110.0030.00716.86
7.2.100.0070.00716.77
7.2.90.0000.00916.79
7.2.80.0080.00317.07
7.2.70.0070.00417.12
7.2.60.0110.00316.91
7.2.50.0000.01317.06
7.2.40.0030.01317.01
7.2.30.0060.00616.80
7.2.20.0060.00916.99
7.2.10.0100.00717.03
7.2.00.0070.00718.14
7.1.250.0070.00315.76
7.1.240.0030.00615.86
7.1.230.0030.00916.02
7.1.220.0000.01015.95
7.1.210.0040.00416.00
7.1.200.0040.00815.69
7.1.190.0000.00815.56
7.1.180.0090.00615.94
7.1.170.0090.00315.58
7.1.160.0030.00515.72
7.1.150.0070.00615.76
7.1.140.0030.01015.80
7.1.130.0000.01215.95
7.1.120.0070.00715.80
7.1.110.0090.00315.73
7.1.100.0040.01117.02
7.1.90.0100.00015.84
7.1.80.0000.01115.83
7.1.70.0040.00616.40
7.1.60.0060.01017.65
7.1.50.0050.00916.35
7.1.40.0000.01315.89
7.1.30.0030.00615.97
7.1.20.0100.00315.81
7.1.10.0030.00715.79
7.1.00.0020.04318.93
7.0.330.0090.00315.42
7.0.320.0030.00915.42
7.0.310.0060.00315.44
7.0.300.0030.00615.15
7.0.290.0090.00015.52
7.0.280.0070.00715.48
7.0.270.0040.00415.59
7.0.260.0040.00415.42
7.0.250.0060.00315.54
7.0.240.0090.00315.24
7.0.230.0030.00615.22
7.0.220.0060.00315.58
7.0.210.0060.00615.62
7.0.200.0250.00315.06
7.0.190.0030.00715.49
7.0.180.0000.01015.18
7.0.170.0040.00415.29
7.0.160.0000.01015.31
7.0.150.0070.00315.61
7.0.140.0080.00815.64
7.0.130.0000.01115.65
7.0.120.0080.00015.51
7.0.110.0000.00815.15
7.0.100.0030.01015.63
7.0.90.0030.00715.54
7.0.80.0040.00715.64
7.0.70.0030.00715.54
7.0.60.0170.03218.48
7.0.50.0030.03416.64
7.0.40.0030.03216.78
7.0.30.0130.03816.90
7.0.20.0160.04116.73
7.0.10.0050.04716.89
7.0.00.0050.02516.90
5.6.380.0030.01014.66
5.6.370.0030.00714.80
5.6.360.0030.01014.53
5.6.350.0090.00314.55
5.6.340.0000.01314.66
5.6.330.0070.00714.52
5.6.320.0070.00714.43
5.6.310.0120.00414.20
5.6.300.0080.00414.69
5.6.290.0030.00914.40
5.6.280.0030.02017.97
5.6.270.0060.00314.65
5.6.260.0120.00014.42
5.6.250.0070.00314.49
5.6.240.0120.00314.61
5.6.230.0030.01014.47
5.6.220.0070.00414.77
5.6.210.0060.04217.55
5.6.200.0080.02816.35
5.6.190.0030.02517.56
5.6.180.0190.03017.44
5.6.170.0160.03417.43
5.6.160.0030.03017.54
5.6.150.0040.02116.25
5.6.140.0050.04416.30
5.6.130.0060.03716.34
5.6.120.0040.02517.75
5.6.110.0020.02717.57
5.6.100.0180.03017.84
5.6.90.0080.02517.44
5.6.80.0100.04017.36
5.6.70.0000.00914.62
5.6.60.0080.00314.44
5.6.50.0000.01114.40
5.6.40.0030.00714.39
5.6.30.0030.00714.29
5.6.20.0040.00814.46
5.6.10.0030.00714.28
5.6.00.0030.00914.66
5.5.380.0060.00011.22
5.5.370.0000.00811.16
5.5.360.0060.00311.50
5.5.350.2160.01815.67
5.5.340.0080.04014.64
5.5.330.0000.02615.89
5.5.320.0270.02215.65
5.5.310.0140.04215.92
5.5.300.0010.02314.60
5.5.290.0060.03814.65
5.5.280.0050.03616.22
5.5.270.0050.03916.26
5.5.260.0000.03416.02
5.5.250.0110.03615.87
5.5.240.0180.03515.65
5.5.230.0050.00311.13
5.5.220.0000.00811.43
5.5.210.0000.00711.21
5.5.200.0080.00011.19
5.5.190.0050.00011.44
5.5.180.0030.00711.09
5.5.170.0060.00311.28
5.5.160.0000.01011.22
5.5.150.0060.00611.36
5.5.140.0030.00311.21
5.5.130.0030.00611.05
5.5.120.0040.00411.51
5.5.110.0030.00311.43
5.5.100.0060.00311.52
5.5.90.0060.00611.35
5.5.80.0030.00310.98
5.5.70.0070.00311.16
5.5.60.0040.00411.32
5.5.50.0070.00311.02
5.5.40.0050.00311.11
5.5.30.0030.00911.07
5.5.20.0070.00311.41
5.5.10.0000.00811.43
5.5.00.0030.00511.30

preferences:
46.25 ms | 401 KiB | 5 Q