3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a implements \Iterator, \Countable, \ArrayAccess { private $a; private $b; private $c; private $keys = [ 'a', 'b', 'c' ]; private $pointer; public function __construct($a = null, $b = null, $c = null) { $this->a = $a; $this->b = $b; $this->c = $c; } public function count() { $pointer = 0; foreach ($this as $element) { if ($element) { $pointer++; } } return $pointer; } public function current() { $key = $this->key(); return $this->{$key}; } public function key() { return $this->keys[$this->pointer]; } public function next() { $this->pointer++; } public function valid() { return $this->pointer < count($this->keys); } public function rewind() { $this->pointer = 0; } public function offsetExists($offset) { return isset($this->{$offset}); } public function offsetGet($offset) { return $this->{$offset}; } public function offsetSet($offset, $value) { throw new \BadMethodCallException('Object does not implement set'); } public function offsetUnset($offset) { throw new \BadMethodCallException('Value object does not implement modification via unset'); } } $me = new a(1,2,3); var_dump($me->count()); foreach ($me as $key => $el) { if ($key === 'b') { $me[$key] = 111; } } var_dump($me);

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.0100.01016.88
8.3.50.0140.00921.21
8.3.40.0120.00318.96
8.3.30.0120.00618.97
8.3.20.0060.00320.35
8.3.10.0050.00323.66
8.3.00.0080.00019.81
8.2.180.0040.01116.63
8.2.170.0110.00422.96
8.2.160.0100.01020.29
8.2.150.0030.00524.18
8.2.140.0000.00924.66
8.2.130.0050.00326.16
8.2.120.0090.00017.75
8.2.110.0060.00321.97
8.2.100.0060.00617.88
8.2.90.0060.00319.17
8.2.80.0060.00317.97
8.2.70.0040.00417.75
8.2.60.0050.00317.93
8.2.50.0030.00618.07
8.2.40.0030.00719.43
8.2.30.0040.00418.11
8.2.20.0000.00817.86
8.2.10.0000.00718.06
8.2.00.0040.00418.06
8.1.280.0130.00625.92
8.1.270.0090.00020.31
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0090.00022.46
8.1.230.0060.00617.42
8.1.220.0030.00617.74
8.1.210.0000.00918.77
8.1.200.0060.00317.47
8.1.190.0040.00417.48
8.1.180.0040.00418.10
8.1.170.0030.00618.77
8.1.160.0030.00521.95
8.1.150.0040.00418.82
8.1.140.0080.00017.57
8.1.130.0000.00717.77
8.1.120.0060.00317.43
8.1.110.0040.00417.55
8.1.100.0000.00717.59
8.1.90.0040.00417.39
8.1.80.0060.00317.43
8.1.70.0030.00317.45
8.1.60.0060.00617.64
8.1.50.0000.00817.59
8.1.40.0030.00617.44
8.1.30.0030.00517.67
8.1.20.0000.00817.62
8.1.10.0070.00017.50
8.1.00.0030.00617.53
8.0.300.0020.00518.77
8.0.290.0080.00017.00
8.0.280.0070.00018.51
8.0.270.0070.00017.32
8.0.260.0030.00317.31
8.0.250.0000.00716.94
8.0.240.0040.00416.97
8.0.230.0000.00717.07
8.0.220.0040.00417.04
8.0.210.0000.00816.90
8.0.200.0060.00317.00
8.0.190.0070.00317.14
8.0.180.0000.00717.08
8.0.170.0030.00616.96
8.0.160.0070.00016.91
8.0.150.0040.00416.87
8.0.140.0000.01016.99
8.0.130.0000.00713.44
8.0.120.0000.00917.03
8.0.110.0070.00016.93
8.0.100.0040.00417.05
8.0.90.0050.00216.91
8.0.80.0090.00617.04
8.0.70.0080.00016.91
8.0.60.0000.00717.00
8.0.50.0050.00217.02
8.0.30.0110.01017.11
8.0.20.0130.00617.44
8.0.10.0020.00517.05
8.0.00.0090.01016.79
7.4.330.0000.00515.08
7.4.320.0000.00716.58
7.4.300.0020.00516.63
7.4.290.0080.00016.67
7.4.280.0050.00516.68
7.4.270.0040.00416.63
7.4.260.0000.01116.68
7.4.250.0000.00816.60
7.4.240.0020.00516.66
7.4.230.0070.00016.54
7.4.220.0070.01716.65
7.4.210.0070.00716.52
7.4.200.0040.00416.73
7.4.160.0130.00316.55
7.4.150.0130.00317.40
7.4.140.0100.00917.86
7.4.130.0100.01016.60
7.4.120.0080.00916.60
7.4.110.0070.01016.64
7.4.100.0090.00916.56
7.4.90.0120.00616.62
7.4.80.0030.01819.39
7.4.70.0160.00016.57
7.4.60.0130.00316.45
7.4.50.0000.00816.66
7.4.40.0000.01516.48
7.4.30.0040.01216.69
7.4.00.0090.00915.24
7.3.330.0000.00513.27
7.3.320.0000.00613.21
7.3.310.0040.00416.34
7.3.300.0070.00016.41
7.3.290.0090.00916.37
7.3.280.0090.01116.40
7.3.270.0090.01617.40
7.3.260.0160.00716.61
7.3.250.0080.01016.58
7.3.240.0110.00516.46
7.3.230.0040.01516.41
7.3.210.0080.00816.61
7.3.200.0100.00616.52
7.3.190.0070.01316.48
7.3.180.0070.01016.47
7.3.170.0030.01316.40
7.3.160.0130.00916.48
7.3.120.0070.01014.92
7.3.110.0000.01314.65
7.3.100.0040.00815.09
7.3.90.0030.01414.65
7.3.80.0070.01014.62
7.3.70.0040.00814.85
7.3.60.0000.01514.84
7.3.50.0090.00314.92
7.3.40.0060.00914.82
7.3.30.0070.01314.70
7.3.20.0070.00316.89
7.3.10.0040.01116.75
7.3.00.0040.00716.73
7.2.330.0090.00916.66
7.2.320.0090.00816.74
7.2.310.0120.00416.82
7.2.300.0120.01216.61
7.2.290.0130.00716.80
7.2.250.0000.01815.12
7.2.240.0070.01315.20
7.2.230.0040.01214.88
7.2.220.0070.01015.25
7.2.210.0140.00315.38
7.2.200.0000.00915.23
7.2.190.0160.00014.91
7.2.180.0140.00415.21
7.2.170.0120.00315.07
7.2.160.0040.00814.84
7.2.150.0070.00716.59
7.2.140.0060.00617.04
7.2.130.0070.01116.98
7.2.120.0000.01317.03
7.2.110.0030.01017.04
7.2.100.0070.00716.72
7.2.90.0000.01416.83
7.2.80.0090.00616.79
7.2.70.0000.01217.04
7.2.60.0060.00617.02
7.2.50.0000.01316.68
7.2.40.0060.00616.71
7.2.30.0030.01016.92
7.2.20.0030.01017.05
7.2.10.0090.00617.10
7.2.00.0050.00618.27
7.1.330.0070.00715.47
7.1.320.0110.00715.61
7.1.310.0090.00315.93
7.1.300.0060.01116.00
7.1.290.0060.00615.85
7.1.280.0100.01015.76
7.1.270.0110.00015.75
7.1.260.0040.00715.88
7.1.250.0100.00315.53
7.1.200.0040.00815.57
7.1.100.0040.00817.91
7.1.70.0000.00716.83
7.1.60.0150.00620.03
7.1.50.0040.00717.05
7.1.00.0030.07722.30
7.0.200.0080.00416.74
7.0.60.0130.06720.05
7.0.50.0000.06317.90
7.0.40.0130.08320.09
7.0.30.0470.06720.07
7.0.20.0230.04020.25
7.0.10.0100.06020.10
7.0.00.0100.05720.46
5.6.280.0070.05320.97
5.6.210.0170.07720.54
5.6.200.0100.08018.25
5.6.190.0070.09020.77
5.6.180.3830.04020.64
5.6.170.0200.05320.45
5.6.160.0030.05720.54
5.6.150.0000.04018.13
5.6.140.0130.07718.28
5.6.130.0070.06018.18
5.6.120.0030.06721.13
5.6.110.0130.08321.01
5.6.100.0070.06721.13
5.6.90.0100.07321.01
5.6.80.0170.07320.52
5.6.70.4170.03720.39
5.5.350.0030.03720.36
5.5.340.0170.07017.93
5.5.330.0130.07720.43
5.5.320.0270.04020.34
5.5.310.0230.04020.30
5.5.300.0030.07318.04
5.5.290.0070.06018.01
5.5.280.0070.04020.78
5.5.270.0170.07720.78
5.5.260.0070.08720.86
5.5.250.0030.04320.63
5.5.240.0330.03020.18
5.4.450.0830.05719.71
5.4.440.0900.07019.32
5.4.430.0470.05719.71
5.4.420.0500.05019.54
5.4.410.0570.06019.48
5.4.400.0570.05319.14
5.4.390.0730.04319.28
5.4.380.0470.05319.38
5.4.370.0530.05019.28
5.4.360.0470.05719.06
5.4.350.0570.04019.23
5.4.340.0470.06019.27
5.4.320.0570.04719.15
5.4.310.0400.06019.03
5.4.300.0470.05319.25
5.4.290.0470.05319.13
5.4.280.0430.05719.27
5.4.270.0530.05319.29
5.4.260.0570.06319.13
5.4.250.0430.06018.83
5.4.240.0430.06019.12
5.4.230.0530.05019.23
5.4.220.0470.05719.08
5.4.210.0630.05019.26
5.4.200.0630.05319.29
5.4.190.0700.04719.05
5.4.180.0600.05719.27
5.4.170.0400.06018.96
5.4.160.0600.04319.23
5.4.150.0500.05319.10
5.4.140.0500.05016.42
5.4.130.0470.04716.33
5.4.120.0530.05316.57
5.4.110.0800.06016.39
5.4.100.0400.05716.63
5.4.90.0730.05316.63
5.4.80.0570.04316.60
5.4.70.0030.04016.55
5.4.60.0230.03316.44
5.4.50.0030.04016.53
5.4.40.0370.04016.38
5.4.30.0200.04716.43
5.4.20.0370.06016.26

preferences:
71.62 ms | 401 KiB | 5 Q