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; public function __construct($array) { if (is_array($array)) { $this->var = $array; } } // Required definition of interface IteratorAggregate public function getIterator() { return new MyIterator($this->var); } public function add($value) { $this->items[$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.0000.01516.73
8.3.50.0100.01222.15
8.3.40.0110.00418.88
8.3.30.0060.00919.09
8.3.20.0040.00420.07
8.3.10.0040.00423.67
8.3.00.0050.00319.13
8.2.180.0120.00316.88
8.2.170.0070.00722.96
8.2.160.0130.00020.52
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00222.22
8.2.110.0000.00922.07
8.2.100.0080.00417.71
8.2.90.0000.00819.22
8.2.80.0040.00417.97
8.2.70.0000.00817.48
8.2.60.0040.00817.80
8.2.50.0000.00818.07
8.2.40.0040.00417.92
8.2.30.0000.00718.04
8.2.20.0040.00417.71
8.2.10.0000.00818.05
8.2.00.0000.00717.72
8.1.280.0110.00425.92
8.1.270.0040.00421.96
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0030.00623.88
8.1.230.0040.00719.16
8.1.220.0040.00417.77
8.1.210.0030.00518.77
8.1.200.0000.00817.35
8.1.190.0000.00817.66
8.1.180.0000.01018.10
8.1.170.0060.00318.63
8.1.160.0060.00322.13
8.1.150.0030.00618.54
8.1.140.0000.00817.43
8.1.130.0030.00317.70
8.1.120.0060.00317.38
8.1.110.0000.00917.51
8.1.100.0050.00217.50
8.1.90.0040.00417.43
8.1.80.0040.00417.47
8.1.70.0050.00317.37
8.1.60.0000.00917.58
8.1.50.0040.00417.45
8.1.40.0000.00817.56
8.1.30.0050.00317.57
8.1.20.0000.00817.70
8.1.10.0040.00417.62
8.1.00.0000.00817.59
8.0.300.0040.00418.77
8.0.290.0040.00417.17
8.0.280.0030.00318.51
8.0.270.0050.00217.29
8.0.260.0030.00316.75
8.0.250.0000.00716.88
8.0.240.0000.00716.86
8.0.230.0040.00416.86
8.0.220.0030.00316.90
8.0.210.0030.00316.89
8.0.200.0040.00416.88
8.0.190.0040.00416.98
8.0.180.0030.00316.95
8.0.170.0000.00816.89
8.0.160.0000.00716.97
8.0.150.0000.00816.75
8.0.140.0030.00616.82
8.0.130.0060.00313.34
8.0.120.0040.00416.89
8.0.110.0040.00416.91
8.0.100.0030.00616.78
8.0.90.0000.00717.00
8.0.80.0060.01616.84
8.0.70.0070.00016.90
8.0.60.0030.00616.92
8.0.50.0000.00716.91
8.0.30.0130.00717.07
8.0.20.0080.01317.40
8.0.10.0000.00717.08
8.0.00.0110.00716.68
7.4.330.0030.00315.14
7.4.320.0030.00316.51
7.4.300.0030.00316.51
7.4.290.0070.00016.66
7.4.280.0030.00316.54
7.4.270.0030.00316.46
7.4.260.0000.00716.52
7.4.250.0080.00016.40
7.4.240.0020.00516.54
7.4.230.0000.00716.35
7.4.220.0110.00716.69
7.4.210.0050.00916.57
7.4.200.0070.00016.70
7.4.190.0000.00716.66
7.4.160.0120.00416.59
7.4.150.0060.01217.40
7.4.140.0090.00817.86
7.4.130.0050.01316.49
7.4.120.0070.01016.63
7.4.110.0090.00916.36
7.4.100.0160.00616.51
7.4.90.0030.01416.54
7.4.80.0060.01319.39
7.4.70.0100.00716.68
7.4.60.0030.01416.43
7.4.50.0000.00816.68
7.4.40.0070.01122.77
7.4.30.0080.01216.64
7.4.00.0060.00915.18
7.3.330.0000.00513.38
7.3.320.0000.00513.32
7.3.310.0000.00716.39
7.3.300.0050.00216.24
7.3.290.0040.01116.39
7.3.280.0120.00416.35
7.3.270.0100.00717.40
7.3.260.0090.00916.62
7.3.250.0090.00916.69
7.3.240.0090.00916.48
7.3.230.0070.01116.70
7.3.210.0060.01216.29
7.3.200.0100.01019.39
7.3.190.0110.01116.77
7.3.180.0090.00616.30
7.3.170.0030.01216.63
7.3.160.0090.00916.42
7.3.120.0060.00915.02
7.3.10.0000.01516.59
7.3.00.0030.01016.36
7.2.330.0080.01116.70
7.2.320.0160.00716.82
7.2.310.0070.01816.82
7.2.300.0060.01016.86
7.2.290.0120.00916.67
7.2.130.0060.01216.50
7.2.120.0060.00916.73
7.2.110.0160.00716.69
7.2.100.0210.00316.37
7.2.90.0100.01016.87
7.2.80.0130.01216.63
7.2.70.0160.00816.74
7.2.60.0170.01016.73
7.2.50.0200.00716.45
7.2.40.0160.00516.76
7.2.30.0150.01516.62
7.2.20.0120.00416.51
7.2.10.0060.00617.07
7.2.00.0090.00916.73
7.1.250.0150.00415.62
7.1.200.0040.01115.64
7.1.100.0040.00818.25
7.1.70.0030.00617.21
7.1.60.0070.01719.33
7.1.50.0080.01517.11
7.1.00.0030.07722.25
7.0.200.0040.00416.48
7.0.140.0100.07022.00
7.0.100.0100.07719.93
7.0.90.0130.07319.97
7.0.80.0070.07319.98
7.0.70.0400.07719.97
7.0.60.0270.07019.83
7.0.50.0200.05720.19
7.0.40.0170.05020.12
7.0.30.0030.04720.10
7.0.20.0070.05720.19
7.0.10.0000.04720.10
7.0.00.0070.04720.07
5.6.280.0000.07721.13
5.6.250.0170.07320.83
5.6.240.0200.07320.64
5.6.230.0100.03720.76
5.6.220.0100.08020.54
5.6.210.0130.05320.68
5.6.200.0030.05021.16
5.6.190.0070.04020.96
5.6.180.0070.04021.13
5.6.170.0030.04321.19
5.6.160.0100.03721.09
5.6.150.0030.04321.16
5.6.140.0000.09321.05
5.6.130.0030.05321.08
5.6.120.0200.04721.06
5.6.110.0070.07721.11
5.6.100.0070.06321.17
5.6.90.0000.05020.93
5.6.80.0100.05320.48
5.6.70.0030.04720.33
5.6.60.0100.05720.46
5.6.50.0030.04320.48
5.6.40.0100.05320.41
5.6.30.0100.03720.31
5.6.20.0070.03720.38
5.6.10.0030.04020.50
5.6.00.0070.03320.45
5.5.380.0100.07320.43
5.5.370.0000.07320.43
5.5.360.0170.07020.35
5.5.350.0070.04020.43
5.5.340.0070.08720.81
5.5.330.0030.04320.91
5.5.320.0130.03720.78
5.5.310.0070.04320.91
5.5.300.0170.03020.93
5.5.290.0100.08020.66
5.5.280.0070.08720.84
5.5.270.0070.04320.93
5.5.260.0070.08020.89
5.5.250.0000.04720.59
5.5.240.0100.08020.30
5.5.230.0030.04020.22
5.5.220.0100.05320.29
5.5.210.0030.04320.20
5.5.200.0070.03720.23
5.5.190.0030.04720.19
5.5.180.0030.04020.20
5.5.160.0070.03720.25
5.5.150.0070.03720.16
5.5.140.0070.03720.16
5.5.130.0070.04020.29
5.5.120.0070.03020.16
5.5.110.0070.03320.16
5.5.100.0000.04320.10
5.5.90.0130.05020.02
5.5.80.0100.03020.18
5.5.70.0030.04720.06
5.5.60.0030.04720.15
5.5.50.0100.03720.07
5.5.40.0170.07720.10
5.5.30.0070.07319.97
5.5.20.0070.08020.00
5.5.10.0030.07720.09
5.5.00.0070.05720.10
5.4.450.0070.06019.33
5.4.440.0030.09019.45
5.4.430.0030.04019.52
5.4.420.0100.04719.27
5.4.410.0030.04319.35
5.4.400.0100.04018.95
5.4.390.0030.04019.09
5.4.380.0100.03719.03
5.4.370.0070.05019.20
5.4.360.0030.05319.03
5.4.350.0030.04019.03
5.4.340.0000.05319.14
5.4.320.0070.03719.08
5.4.310.0070.03718.85
5.4.300.0030.03719.15
5.4.290.0030.03719.18
5.4.280.0000.04019.04
5.4.270.0070.03319.09
5.4.260.0030.04319.13
5.4.250.0030.04319.20
5.4.240.0030.03318.88
5.4.230.0030.03718.84
5.4.220.0070.03319.03
5.4.210.0000.06319.04
5.4.200.0070.08019.20
5.4.190.0130.06719.02
5.4.180.0100.07718.95
5.4.170.0100.07318.87
5.4.160.0100.07319.02
5.4.150.0070.07718.88
5.4.140.0070.05316.36
5.4.130.0070.07316.37
5.4.120.0030.07316.27
5.4.110.0030.08016.47
5.4.100.0170.03316.43
5.4.90.0030.07716.43
5.4.80.0170.06316.34
5.4.70.0130.07016.47
5.4.60.0100.03316.37
5.4.50.0130.07016.40
5.4.40.0130.07016.34
5.4.30.0070.07316.31
5.4.20.0100.08016.45
5.4.10.0030.08016.41
5.4.00.0100.05315.84
5.3.290.0030.03714.62
5.3.280.0000.04014.65
5.3.270.0030.06014.74
5.3.260.0130.07314.69
5.3.250.0070.06714.74
5.3.240.0100.05014.69
5.3.230.0030.08314.67
5.3.220.0030.05314.65
5.3.210.0170.06314.52
5.3.200.0230.05714.55
5.3.190.0070.04014.61
5.3.180.0100.05314.63
5.3.170.0070.07714.56
5.3.160.0100.06314.72
5.3.150.0270.05714.64
5.3.140.0070.07314.60
5.3.130.0070.07014.63
5.3.120.0100.07314.63
5.3.110.0170.06714.57
5.3.100.0100.07314.11
5.3.90.0070.05314.10
5.3.80.0030.08014.15
5.3.70.0070.07314.14
5.3.60.0170.06714.11
5.3.50.0030.08013.87
5.3.40.0030.08013.89
5.3.30.0100.06713.99
5.3.20.0030.05713.70
5.3.10.0070.07313.70
5.3.00.0100.05713.72
5.2.170.0100.06013.17
5.2.160.0070.05713.17
5.2.150.0100.06013.17
5.2.140.0100.06013.17
5.2.130.0100.06013.17
5.2.120.0130.03013.17
5.2.110.0130.04713.17
5.2.100.0100.05013.17
5.2.90.0070.06013.17
5.2.80.0030.06313.17
5.2.70.0030.06313.17
5.2.60.0070.06013.17
5.2.50.0170.04713.17
5.2.40.0100.06013.17
5.2.30.0070.06013.17
5.2.20.0070.05713.17
5.2.10.0000.04013.17
5.2.00.0000.06013.17
5.1.60.0130.02013.17
5.1.50.0100.02313.17
5.1.40.0000.05713.17
5.1.30.0030.03013.17
5.1.20.0030.05713.17
5.1.10.0000.05313.17
5.1.00.0070.04013.17
5.0.50.0070.04313.17
5.0.40.0030.04313.17
5.0.30.0000.05313.17
5.0.20.0030.04313.17
5.0.10.0030.04013.17
5.0.00.0000.06013.17
4.4.90.0030.03313.17
4.4.80.0070.02713.17
4.4.70.0000.03313.17
4.4.60.0070.03013.17
4.4.50.0070.03013.17
4.4.40.0030.05313.17
4.4.30.0030.04313.17
4.4.20.0000.03713.17
4.4.10.0070.03013.17
4.4.00.0030.05013.17
4.3.110.0000.02713.17
4.3.100.0030.03313.17
4.3.90.0100.02313.17
4.3.80.0000.05013.17
4.3.70.0000.03713.17
4.3.60.0030.03313.17
4.3.50.0000.02713.17
4.3.40.0030.03013.17
4.3.30.0030.03713.17
4.3.20.0000.04013.17
4.3.10.0030.03313.17
4.3.00.0000.03713.17

preferences:
48.69 ms | 401 KiB | 5 Q