3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { private $var = array(); public function __construct($array) { if (is_array($array)) { $this->var = $array; } } public function rewind() { echo "rewinding\n"; reset($this->var); } public function current() { $var = current($this->var); echo "current: $var\n"; return $var; } public function key() { $var = key($this->var); echo "key: $var\n"; return $var; } public function next() { $var = next($this->var); echo "next: $var\n"; return $var; } public function valid() { $key = key($this->var); $var = ($key !== NULL && $key !== FALSE); echo "valid: $var\n"; return $var; } } class MyCollection implements IteratorAggregate { private $var = array(); private $count = 0; // Required definition of interface IteratorAggregate public function getIterator() { return new MyIterator($this->var); } public function add($value) { $this->var[$this->count++] = $value; } } $values = array('value 1','value 2','value 3'); $coll = new MyCollection($values); foreach ($coll as $key => $val) { echo "key/value: [$key -> $val]\n\n"; } ?>

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.00618.55
8.3.50.0100.01022.11
8.3.40.0100.01018.83
8.3.30.0070.01418.59
8.3.20.0030.00518.76
8.3.10.0030.00521.14
8.3.00.0070.00023.56
8.2.180.0110.00716.88
8.2.170.0140.00322.96
8.2.160.0100.00320.52
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0070.00020.96
8.2.110.0100.00019.21
8.2.100.0130.00017.84
8.2.90.0050.00319.17
8.2.80.0000.00817.97
8.2.70.0000.00817.50
8.2.60.0000.00817.91
8.2.50.0120.00018.07
8.2.40.0030.00518.22
8.2.30.0000.00819.43
8.2.20.0000.00717.73
8.2.10.0000.00817.75
8.2.00.0030.00717.82
8.1.280.0150.00325.92
8.1.270.0060.00323.99
8.1.260.0140.00326.35
8.1.250.0040.00428.09
8.1.240.0030.01523.71
8.1.230.0040.00720.89
8.1.220.0060.00318.77
8.1.210.0040.00419.09
8.1.200.0030.00617.35
8.1.190.0030.00517.53
8.1.180.0050.00318.10
8.1.170.0080.00018.59
8.1.160.0040.00418.81
8.1.150.0070.00018.56
8.1.140.0040.00417.34
8.1.130.0000.00717.84
8.1.120.0070.00017.51
8.1.110.0040.00417.53
8.1.100.0030.00417.52
8.1.90.0000.00717.47
8.1.80.0080.00017.38
8.1.70.0040.00417.43
8.1.60.0000.01217.52
8.1.50.0040.00417.55
8.1.40.0040.00417.57
8.1.30.0070.00017.66
8.1.20.0030.00617.63
8.1.10.0000.00717.62
8.1.00.0060.00317.54
8.0.300.0070.00020.01
8.0.290.0030.00617.18
8.0.280.0050.00218.46
8.0.270.0000.00717.27
8.0.260.0000.00716.90
8.0.250.0000.00816.96
8.0.240.0040.00416.95
8.0.230.0070.00016.84
8.0.220.0000.00716.79
8.0.210.0000.00716.93
8.0.200.0000.00616.84
8.0.190.0030.00316.91
8.0.180.0070.00016.95
8.0.170.0080.00016.91
8.0.160.0040.00416.80
8.0.150.0030.00316.89
8.0.140.0000.00816.77
8.0.130.0070.00013.32
8.0.120.0040.00416.91
8.0.110.0070.00016.76
8.0.100.0000.00716.76
8.0.90.0070.00016.77
8.0.80.0120.00316.86
8.0.70.0000.00816.84
8.0.60.0030.00517.02
8.0.50.0000.00716.95
8.0.30.0090.00916.94
8.0.20.0130.00517.40
8.0.10.0000.00716.92
8.0.00.0080.01216.73
7.4.330.0050.00016.73
7.4.320.0000.00616.53
7.4.300.0060.00016.54
7.4.290.0070.00016.63
7.4.280.0000.00716.52
7.4.270.0030.00616.60
7.4.260.0030.00313.28
7.4.250.0040.00416.52
7.4.240.0000.00816.55
7.4.230.0040.00416.37
7.4.220.0070.01016.39
7.4.210.0070.01016.57
7.4.200.0000.00716.42
7.4.190.0030.00316.63
7.4.160.0140.00416.45
7.4.150.0070.01117.40
7.4.140.0050.01217.86
7.4.130.0100.00716.56
7.4.120.0110.00816.42
7.4.110.0040.01316.28
7.4.100.0140.00316.55
7.4.90.0120.00616.42
7.4.80.0030.01419.39
7.4.70.0070.01116.25
7.4.60.0030.01416.45
7.4.50.0040.00416.48
7.4.40.0000.01022.77
7.4.30.0070.01116.60
7.4.00.0060.00914.90
7.3.330.0000.00613.32
7.3.320.0050.00313.29
7.3.310.0070.00016.30
7.3.300.0000.00716.27
7.3.290.0100.01016.38
7.3.280.0050.01016.33
7.3.270.0130.00417.40
7.3.260.0120.01218.24
7.3.250.0140.00516.43
7.3.240.0100.00716.32
7.3.230.0130.00316.45
7.3.210.0060.00916.57
7.3.200.0130.00719.39
7.3.190.0140.00716.30
7.3.180.0120.00316.44
7.3.170.0080.00716.53
7.3.160.0030.01316.60
7.3.120.0030.01414.87
7.2.330.0070.01116.63
7.2.320.0100.00716.68
7.2.310.0100.01016.67
7.2.300.0090.00916.54
7.2.290.0190.00316.52
7.2.60.0060.00616.69
7.1.200.0030.01015.91
7.1.100.0040.01117.97
7.1.70.0070.00016.93
7.1.60.0140.01119.08
7.1.50.0070.01416.96
7.1.00.0030.05022.31
7.0.200.0070.00316.78
7.0.140.0030.09022.00
7.0.100.0070.06720.07
7.0.90.0000.08720.00
7.0.80.0270.07020.05
7.0.70.0100.08020.19
7.0.60.0070.08019.95
7.0.50.0100.08020.35
7.0.40.0130.07320.05
7.0.30.0130.07720.19
7.0.20.0200.06019.95
7.0.10.0100.07320.09
7.0.00.0130.06720.11
5.6.280.0100.06720.93
5.6.250.0130.06720.58
5.6.240.0030.06020.63
5.6.230.0100.07020.69
5.6.220.0100.07720.63
5.6.210.0070.08720.70
5.6.200.0100.07320.97
5.6.190.0100.07721.03
5.6.180.0030.09021.03
5.6.170.0030.08321.02
5.6.160.0130.07720.98
5.6.150.0070.08021.08
5.6.140.0100.07721.02
5.6.130.0070.08321.04
5.6.120.0030.08020.95
5.6.110.0200.07020.95
5.6.100.0130.08321.02
5.6.90.0100.04721.05
5.6.80.0030.05720.41
5.6.70.0130.07320.51
5.6.60.0100.07020.43
5.6.50.0030.05320.48
5.6.40.0070.07320.33
5.6.30.0170.05720.49
5.6.20.0100.07320.39
5.6.10.0100.06720.39
5.6.00.0100.08020.38
5.5.380.0170.07720.39
5.5.370.0100.07320.38
5.5.360.0100.05020.49
5.5.350.0030.09020.46
5.5.340.0070.06320.75
5.5.330.0000.06720.95
5.5.320.0130.06720.80
5.5.310.0100.04720.82
5.5.300.0130.07720.87
5.5.290.0100.08020.89
5.5.280.0100.06720.88
5.5.270.0130.06720.65
5.5.260.0100.07320.94
5.5.250.0100.06720.71
5.5.240.0230.06020.28
5.5.230.0100.08020.27
5.5.220.0130.08320.16
5.5.210.0100.07320.27
5.5.200.0130.06020.23
5.5.190.0000.05020.15
5.5.180.0170.07020.17
5.5.160.0030.08720.26
5.5.150.0000.08320.23
5.5.140.0130.04320.28
5.5.130.0070.08320.31
5.5.120.0030.05720.29
5.5.110.0070.08020.14
5.5.100.0100.07720.12
5.5.90.0100.07720.08
5.5.80.0030.07320.18
5.5.70.0170.07020.02
5.5.60.0100.07320.08
5.5.50.0030.05020.07
5.5.40.0070.06719.95
5.5.30.0070.07320.07
5.5.20.0100.10020.16
5.5.10.0130.07020.07
5.5.00.0070.05019.97
5.4.450.0000.06719.21
5.4.440.0130.06319.46
5.4.430.0100.08319.46
5.4.420.0030.06019.45
5.4.410.0030.08319.10
5.4.400.0100.07719.21
5.4.390.0100.07319.03
5.4.380.0070.07019.21
5.4.370.0130.07019.16
5.4.360.0070.08018.98
5.4.350.0070.04719.04
5.4.340.0130.06019.19
5.4.320.0100.04718.86
5.4.310.0030.07719.17
5.4.300.0130.06719.12
5.4.290.0070.07719.15
5.4.280.0070.07019.16
5.4.270.0170.06318.95
5.4.260.0130.06719.15
5.4.250.0030.05719.11
5.4.240.0230.05719.16
5.4.230.0070.05719.02
5.4.220.0070.07719.12
5.4.210.0070.07719.09
5.4.200.0030.08018.84
5.4.190.0070.08019.22
5.4.180.0070.06318.94
5.4.170.0030.08019.02
5.4.160.0070.04719.00
5.4.150.0030.07019.02
5.4.140.0030.04316.33
5.4.130.0070.05716.43
5.4.120.0100.07016.33
5.4.110.0000.05716.51
5.4.100.0100.06316.47
5.4.90.0070.05316.43
5.4.80.0070.07716.47
5.4.70.0030.07716.44
5.4.60.0070.06316.36
5.4.50.0030.07716.37
5.4.40.0030.04316.34
5.4.30.0070.07716.48
5.4.20.0100.07016.49
5.4.10.0030.05016.52
5.4.00.0130.06315.79
5.3.290.0070.07714.74
5.3.280.0130.06314.75
5.3.270.0100.06314.77
5.3.260.0130.07014.66
5.3.250.0000.06714.72
5.3.240.0030.04314.58
5.3.230.0100.07014.57
5.3.220.0070.05714.52
5.3.210.0070.05714.54
5.3.200.0030.04014.51
5.3.190.0030.06714.57
5.3.180.0100.07014.65
5.3.170.0030.06714.71
5.3.160.0100.06014.70
5.3.150.0070.07714.51
5.3.140.0100.06014.61
5.3.130.0130.07014.50
5.3.120.0070.07314.66
5.3.110.0030.07014.58
5.3.100.0070.07714.15
5.3.90.0070.04714.16
5.3.80.0030.06314.06
5.3.70.0070.06714.13
5.3.60.0100.07014.05
5.3.50.0070.07714.03
5.3.40.0170.06313.96
5.3.30.0030.08014.05
5.3.20.0070.05013.78
5.3.10.0100.05713.68
5.3.00.0070.06713.67
5.2.170.0030.06011.11
5.2.160.0030.05711.26
5.2.150.0000.05011.22
5.2.140.0030.06311.17
5.2.130.0030.03011.16
5.2.120.0070.06011.23
5.2.110.0070.06011.05
5.2.100.0070.03711.05
5.2.90.0000.03311.19
5.2.80.0100.05311.13
5.2.70.0100.05711.22
5.2.60.0030.05711.14
5.2.50.0070.07011.17
5.2.40.0070.06011.05
5.2.30.0000.06011.10
5.2.20.0100.05711.04
5.2.10.0030.03710.84
5.2.00.0070.05710.73
5.1.60.0100.0479.87
5.1.50.0030.05010.07
5.1.40.0070.03310.00
5.1.30.0070.03010.43
5.1.20.0130.02710.44
5.1.10.0030.02710.18
5.1.00.0070.0239.93
5.0.50.0030.0208.61
5.0.40.0000.0278.45
5.0.30.0100.0278.12
5.0.20.0030.0238.29
5.0.10.0030.0178.12
5.0.00.0000.0308.20
4.4.90.0000.0378.12
4.4.80.0000.0208.12
4.4.70.0030.0378.12
4.4.60.0070.0338.12
4.4.50.0000.0378.12
4.4.40.0030.0338.12
4.4.30.0000.0178.12
4.4.20.0070.0238.12
4.4.10.0070.0108.12
4.4.00.0000.0278.12
4.3.110.0000.0178.12
4.3.100.0000.0178.12
4.3.90.0100.0078.12
4.3.80.0000.0278.12
4.3.70.0000.0178.12
4.3.60.0000.0178.12
4.3.50.0000.0178.12
4.3.40.0000.0238.12
4.3.30.0000.0178.12
4.3.20.0000.0178.12
4.3.10.0000.0178.12
4.3.00.0000.0178.12

preferences:
49.5 ms | 401 KiB | 5 Q