3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayStorage implements Iterator, ArrayAccess { private $holder = []; private $instanceName; public function __construct($instanceName) { if (!class_exists($instanceName)) { throw new \Exception('Class '.$instanceName.' was not found'); } $this->instanceName = $instanceName; } public function rewind() { reset($this->holder); } public function current() { return current($this->holder); } public function key() { return key($this->holder); } public function next() { next($this->holder); } public function valid() { return false !== $this->current(); } public function offsetSet($offset, $value) { if (!($value instanceof $this->instanceName)) { throw new \Exception('Storage allows only '.$this->instanceName.' instances'); } if (is_null($offset)) { $this->holder[] = $value; } else { $this->holder[$offset] = $value; } } public function offsetExists($offset) { return isset($this->holder[$offset]); } public function offsetUnset($offset) { unset($this->holder[$offset]); } public function offsetGet($offset) { return isset($this->holder[$offset]) ? $this->holder[$offset] : null; } } class Foo {} class Bar {} $storage = new ArrayStorage('Foo'); $storage[] = new Foo; $storage['baz'] = new Foo; //var_export($storage); foreach ($storage as $key => $value) { echo($key. ' => '.PHP_EOL.var_export($value, 1).PHP_EOL); } $storage['bee'] = new Bar;

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.5.10.0130.00820.38
8.5.00.0130.01020.20
8.4.150.0010.00114.05
8.4.140.0160.00617.98
8.4.130.0120.00820.27
8.4.120.0100.00520.82
8.4.110.0050.00622.23
8.4.100.0120.00818.07
8.4.90.0120.00918.64
8.4.80.0100.01017.95
8.4.70.0030.00518.07
8.4.60.0110.00619.12
8.4.50.0140.00817.87
8.4.40.0070.01417.75
8.4.30.0140.00717.66
8.4.20.0090.00018.08
8.4.10.0030.00617.95
8.3.280.0140.00718.76
8.3.270.0130.00716.73
8.3.260.0160.00516.64
8.3.250.0130.00518.92
8.3.240.0110.00816.69
8.3.230.0090.01016.98
8.3.220.0080.01117.28
8.3.210.0090.00916.84
8.3.200.0060.00316.55
8.3.190.0060.00217.10
8.3.180.0050.00316.75
8.3.170.0040.01419.09
8.3.160.0100.00018.65
8.3.150.0040.01520.97
8.3.140.0100.01016.72
8.3.130.0030.00618.41
8.3.120.0080.00019.29
8.3.110.0040.00420.94
8.3.100.0040.00424.06
8.3.90.0040.00726.77
8.3.80.0070.00316.87
8.3.70.0100.01016.75
8.3.60.0150.00316.87
8.3.50.0120.00622.00
8.3.40.0120.00318.96
8.3.30.0120.00619.25
8.3.20.0040.00420.18
8.3.10.0000.00821.89
8.3.00.0030.00519.80
8.2.290.0100.00820.47
8.2.280.0060.00318.68
8.2.270.0130.00617.20
8.2.260.0120.00320.35
8.2.250.0100.01018.77
8.2.240.0030.01316.73
8.2.230.0090.00022.58
8.2.220.0050.00537.54
8.2.210.0000.00826.77
8.2.200.0030.00616.75
8.2.190.0070.01716.88
8.2.180.0140.00725.92
8.2.170.0120.00319.13
8.2.160.0130.00322.96
8.2.150.0000.00725.66
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00420.68
8.2.110.0000.00822.19
8.2.100.0090.00318.03
8.2.90.0040.00419.26
8.2.80.0000.00818.16
8.2.70.0030.00617.74
8.2.60.0000.00818.16
8.2.50.0060.00318.07
8.2.40.0040.00418.09
8.2.30.0050.00318.25
8.2.20.0030.00617.88
8.2.10.0040.00418.17
8.2.00.0050.00317.78
8.1.330.0090.01021.95
8.1.320.0120.00816.31
8.1.310.0000.00918.34
8.1.300.0040.00418.13
8.1.290.0040.00430.84
8.1.280.0160.00325.92
8.1.270.0080.00022.18
8.1.260.0080.00026.35
8.1.250.0030.00528.09
8.1.240.0100.00023.58
8.1.230.0050.00519.15
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0030.00617.48
8.1.190.0000.00817.54
8.1.180.0000.00818.96
8.1.170.0050.00318.83
8.1.160.0040.00421.95
8.1.150.0040.00418.95
8.1.140.0040.00417.56
8.1.130.0000.00717.80
8.1.120.0070.00017.50
8.1.110.0040.00417.39
8.1.100.0000.00717.41
8.1.90.0000.00717.42
8.1.80.0070.00017.51
8.1.70.0040.00417.41
8.1.60.0080.00017.63
8.1.50.0030.00617.64
8.1.40.0000.00717.59
8.1.30.0030.00617.56
8.1.20.0030.00617.68
8.1.10.0040.00417.60
8.1.00.0040.00417.48
8.0.300.0000.00718.77
8.0.290.0040.00417.17
8.0.280.0070.00018.42
8.0.270.0030.00317.42
8.0.260.0060.00017.31
8.0.250.0030.00317.06
8.0.240.0000.00716.97
8.0.230.0080.00017.08
8.0.220.0050.00516.93
8.0.210.0000.00817.01
8.0.200.0000.00717.07
8.0.190.0040.00417.03
8.0.180.0040.00716.95
8.0.170.0000.00817.05
8.0.160.0040.00416.99
8.0.150.0040.00416.86
8.0.140.0000.00717.01
8.0.130.0000.00613.47
8.0.120.0020.00516.95
8.0.110.0030.00516.92
8.0.100.0000.00716.81
8.0.90.0000.00717.04
8.0.80.0060.00917.06
8.0.70.0050.00317.05
8.0.60.0000.00816.95
8.0.50.0080.00016.87
8.0.30.0110.00817.09
8.0.20.0060.01217.40
8.0.10.0040.00417.02
8.0.00.0120.00816.79
7.4.330.0000.00515.06
7.4.320.0060.00016.58
7.4.300.0030.00316.45
7.4.290.0030.00316.63
7.4.280.0040.00416.65
7.4.270.0030.00316.67
7.4.260.0040.00416.69
7.4.250.0040.00416.43
7.4.240.0000.00816.68
7.4.230.0000.00716.77
7.4.220.0070.01116.53
7.4.210.0100.00516.49
7.4.200.0040.00416.45
7.4.160.0080.00816.64
7.4.150.0130.00717.40
7.4.140.0090.00917.86
7.4.130.0140.00816.61
7.4.120.0070.01016.64
7.4.110.0100.01016.45
7.4.100.0100.00716.67
7.4.90.0070.01016.43
7.4.80.0070.01119.39
7.4.70.0130.01016.55
7.4.60.0070.01016.50
7.4.50.0000.00916.51
7.4.40.0090.00916.55
7.4.30.0100.00616.70
7.4.00.0080.00814.97
7.3.330.0030.00313.33
7.3.320.0000.00613.54
7.3.310.0000.00716.33
7.3.300.0040.00416.38
7.3.290.0120.00516.46
7.3.280.0070.01216.45
7.3.270.0140.01117.40
7.3.260.0090.00916.61
7.3.250.0140.00516.53
7.3.240.0030.01316.64
7.3.230.0080.00816.57
7.3.210.0090.00916.49
7.3.200.0090.00619.39
7.3.190.0150.01016.68
7.3.180.0030.01316.52
7.3.170.0130.00316.60
7.3.160.0120.00616.54
7.3.120.0100.00717.15
7.3.110.0160.00017.15
7.3.100.0070.00717.15
7.3.90.0070.00717.15
7.3.80.0030.01317.15
7.3.70.0100.00617.15
7.3.60.0140.00017.15
7.3.50.0110.00617.15
7.3.40.0110.00317.15
7.3.30.0080.00317.15
7.3.20.0090.00917.15
7.3.10.0120.00317.15
7.3.00.0070.01017.15
7.2.330.0090.00916.71
7.2.320.0110.00616.51
7.2.310.0120.00616.81
7.2.300.0100.00716.74
7.2.290.0190.00716.54
7.2.240.0060.00917.15
7.2.230.0110.00717.15
7.2.220.0000.01417.15
7.2.210.0090.00317.15
7.2.200.0060.00917.15
7.2.190.0040.00817.15
7.2.180.0030.00717.15
7.2.170.0130.00017.15
7.2.160.0100.00717.15
7.2.150.0090.00917.15
7.2.140.0100.00717.15
7.2.130.0040.01517.15
7.2.120.0100.00717.15
7.2.110.0120.00417.15
7.2.100.0130.00017.15
7.2.90.0040.01217.15
7.2.80.0040.01417.15
7.2.70.0100.00317.15
7.2.60.0090.00616.80
7.2.50.0100.00717.15
7.2.40.0070.01017.15
7.2.30.0060.00917.15
7.2.20.0030.01317.18
7.2.10.0030.01217.17
7.2.00.0030.01018.27
7.1.330.0100.00317.15
7.1.320.0070.01017.15
7.1.310.0080.00417.15
7.1.300.0000.01417.15
7.1.290.0000.01717.15
7.1.280.0080.00517.15
7.1.270.0030.01017.15
7.1.260.0000.00917.15
7.1.250.0000.01617.15
7.1.200.0060.00615.89
7.1.100.0030.01018.19
7.1.70.0060.00917.33
7.1.60.0090.00919.29
7.1.50.0060.01917.02
7.1.00.0000.08022.28
7.0.200.0790.00914.75
7.0.140.0030.07022.21
7.0.60.0100.04321.72
7.0.50.0000.04317.89
7.0.40.0100.06720.40
7.0.30.0270.04720.21
7.0.20.0370.07720.33
7.0.10.0100.08020.16
7.0.00.0070.07720.26
5.6.280.0070.07021.14
5.6.210.0070.08720.78
5.6.200.0100.07718.19
5.6.190.0130.04020.41
5.6.180.0400.08020.39
5.6.170.1300.05020.46
5.6.160.0100.07020.54
5.6.150.0030.06018.18
5.6.140.0100.06018.24
5.6.130.0000.06718.18
5.6.120.0070.06321.13
5.6.110.0000.08721.09
5.6.100.0130.07321.13
5.6.90.0070.09321.03
5.6.80.0130.07720.45
5.5.350.0070.07720.34
5.5.340.0030.05717.95
5.5.330.0070.08320.40
5.5.320.0400.07720.46
5.5.310.0200.06720.30
5.5.300.0130.07717.97
5.5.290.0000.09318.02
5.5.280.0070.03720.90
5.5.270.0070.05020.88
5.5.260.0100.07020.77
5.5.250.0170.07320.58
5.5.240.0070.07020.28
5.4.450.0530.07019.52
5.4.440.0470.06719.48
5.4.430.0430.07319.46
5.4.420.0530.06319.39
5.4.410.0500.06719.17
5.4.400.0500.06718.88
5.4.390.0500.07019.14
5.4.380.0530.06719.16
5.4.370.0600.06019.09
5.4.360.0530.04719.15
5.4.350.0570.06018.98
5.4.340.0530.04019.22
5.4.320.0600.06319.13
5.4.310.0430.04318.95
5.4.300.0570.05719.04
5.4.290.0570.06018.98
5.4.280.0400.04019.08
5.4.270.0530.06019.14
5.4.260.0500.06318.85
5.4.250.0530.05318.85
5.4.240.0400.05018.98
5.4.230.0530.05719.15
5.4.220.0600.06019.12
5.4.210.0530.06718.97
5.4.200.0700.05319.23
5.4.190.0470.07018.98
5.4.180.0430.03319.18
5.4.170.0500.06319.10
5.4.160.0500.05018.92
5.4.150.0470.03019.07
5.4.140.0470.05316.34
5.4.130.0470.04316.72
5.4.120.0370.04316.55
5.4.110.0370.03716.40
5.4.100.0400.05716.45
5.4.90.0500.04716.61
5.4.80.0430.06316.62
5.4.70.0400.05016.43
5.4.60.0530.05716.25
5.4.50.0400.03316.48
5.4.40.0370.03716.25
5.4.30.0330.03316.25
5.4.20.0330.03316.52
5.4.10.0330.03716.17
5.4.00.0470.03316.11
5.3.290.0530.06314.88
5.3.280.0500.05714.46
5.3.270.0230.06014.62
5.3.260.0530.03314.70
5.3.250.0370.05014.71
5.3.240.0430.04014.51
5.3.230.0430.05314.50
5.3.220.0300.04014.47
5.3.210.0600.05314.46
5.3.200.0470.06714.48
5.3.190.0400.06714.72
5.3.180.0400.06014.53
5.3.170.0400.06314.61
5.3.160.0470.06314.56
5.3.150.0470.06314.45
5.3.140.0370.03714.56
5.3.130.0300.03714.45
5.3.120.0370.04014.51
5.3.110.0270.04014.66
5.3.100.0330.04314.25
5.3.90.0330.04013.91
5.3.80.0330.04314.17
5.3.70.0330.03013.93
5.3.60.0270.03714.16
5.3.50.0270.04014.00
5.3.40.0300.05014.09
5.3.30.0400.02314.13
5.3.20.0370.03013.69
5.3.10.0270.04013.57
5.3.00.0300.03313.56
5.2.170.0270.02711.36
5.2.160.0200.03311.05
5.2.150.0200.03311.25
5.2.140.0230.03011.25
5.2.130.0200.03311.25
5.2.120.0270.02711.02
5.2.110.0230.03011.02
5.2.100.0270.03011.21
5.2.90.0270.02711.20
5.2.80.0270.02711.09
5.2.70.0200.03711.09
5.2.60.0270.03011.10
5.2.50.0270.04010.93
5.2.40.0170.03010.87
5.2.30.0200.02711.18
5.2.20.0170.03011.18
5.2.10.0170.03310.88
5.2.00.0200.02710.67
5.1.60.0170.03010.39
5.1.50.0030.02710.39
5.1.40.0130.02010.39
5.1.30.0100.02310.42
5.1.20.0130.02010.46
5.1.10.0200.02310.39
5.1.00.0270.03310.39
5.0.50.0100.02010.39
5.0.40.0130.04310.39
5.0.30.0200.06010.39
5.0.20.0170.02710.39
5.0.10.0170.02310.39
5.0.00.0130.06710.39
4.4.90.0100.01710.39
4.4.80.0170.03310.39
4.4.70.0100.01310.39
4.4.60.0100.01310.39
4.4.50.0100.01710.39
4.4.40.0100.02310.39
4.4.30.0070.01310.39
4.4.20.0030.01710.39
4.4.10.0100.01710.39
4.4.00.0130.02710.39
4.3.110.0100.03010.39
4.3.100.0170.03310.39
4.3.90.0170.03310.39
4.3.80.0170.04010.39
4.3.70.0130.02310.39
4.3.60.0170.02010.39
4.3.50.0200.03010.39
4.3.40.0130.05310.39
4.3.30.0070.02010.39
4.3.20.0130.03310.39
4.3.10.0100.02310.39
4.3.00.0070.03010.39

preferences:
190.62 ms | 403 KiB | 5 Q