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; } public $values = array(1,2,3); } 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->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.70.0150.00616.87
8.3.60.0190.00016.75
8.3.50.0120.01022.07
8.3.40.0110.00419.02
8.3.30.0100.00519.04
8.3.20.0080.00020.38
8.3.10.0080.00021.74
8.3.00.0090.00919.25
8.2.180.0100.01018.29
8.2.170.0160.00022.96
8.2.160.0070.01020.39
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0070.00726.16
8.2.120.0000.00722.25
8.2.110.0060.00321.99
8.2.100.0060.00617.72
8.2.90.0080.00019.14
8.2.80.0080.00017.97
8.2.70.0000.00817.25
8.2.60.0000.00817.79
8.2.50.0030.00518.07
8.2.40.0040.00418.22
8.2.30.0030.00718.08
8.2.20.0040.00417.70
8.2.10.0080.00018.22
8.2.00.0060.00317.66
8.1.280.0070.01125.92
8.1.270.0040.01123.82
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0060.00323.88
8.1.230.0090.00318.83
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0000.01017.35
8.1.190.0000.00817.55
8.1.180.0040.00418.10
8.1.170.0070.00418.67
8.1.160.0000.00721.97
8.1.150.0000.00718.67
8.1.140.0070.00017.41
8.1.130.0000.00717.78
8.1.120.0040.00417.55
8.1.110.0060.00317.40
8.1.100.0040.00417.45
8.1.90.0050.00217.48
8.1.80.0030.00517.56
8.1.70.0070.00017.49
8.1.60.0000.00817.62
8.1.50.0050.00317.57
8.1.40.0080.00017.52
8.1.30.0000.00817.61
8.1.20.0000.00817.70
8.1.10.0000.00717.48
8.1.00.0000.00817.52
8.0.300.0000.00718.77
8.0.290.0070.00017.15
8.0.280.0050.00318.49
8.0.270.0040.00417.29
8.0.260.0030.00316.82
8.0.250.0030.00316.91
8.0.240.0060.00317.01
8.0.230.0000.00716.90
8.0.220.0030.00316.82
8.0.210.0030.00316.95
8.0.200.0030.00317.00
8.0.190.0030.00516.97
8.0.180.0040.00416.94
8.0.170.0040.00416.99
8.0.160.0000.00716.99
8.0.150.0070.00016.91
8.0.140.0000.00816.89
8.0.130.0060.00013.40
8.0.120.0000.00916.94
8.0.110.0000.00817.00
8.0.100.0040.00416.82
8.0.90.0080.00016.77
8.0.80.0090.00616.88
8.0.70.0040.00416.76
8.0.60.0000.00716.81
8.0.50.0040.00416.88
8.0.30.0080.01117.11
8.0.20.0090.01017.40
8.0.10.0050.00317.10
8.0.00.0090.00916.77
7.4.330.0000.00515.14
7.4.320.0060.00016.40
7.4.300.0000.00616.59
7.4.290.0000.00716.53
7.4.280.0000.00716.49
7.4.270.0030.00516.53
7.4.260.0040.00416.52
7.4.250.0000.00816.40
7.4.240.0050.00216.61
7.4.230.0000.00816.66
7.4.220.0040.01416.59
7.4.210.0110.00616.61
7.4.200.0020.00516.71
7.4.190.0060.00316.58
7.4.160.0120.01216.35
7.4.150.0040.01317.40
7.4.140.0110.00817.86
7.4.130.0110.00616.65
7.4.120.0090.00816.45
7.4.110.0100.00716.72
7.4.100.0140.00516.58
7.4.90.0070.01016.68
7.4.80.0180.00019.39
7.4.70.0160.00016.66
7.4.60.0090.00816.53
7.4.50.0030.00616.49
7.4.40.0120.00022.77
7.4.30.0070.01016.52
7.4.00.0040.01115.01
7.3.330.0030.00313.40
7.3.320.0070.00013.14
7.3.310.0030.00316.36
7.3.300.0040.00416.32
7.3.290.0080.00816.33
7.3.280.0090.00916.38
7.3.270.0080.00817.40
7.3.260.0140.00316.39
7.3.250.0100.01116.40
7.3.240.0120.01516.59
7.3.230.0090.00916.39
7.3.210.0060.01116.49
7.3.200.0050.01319.39
7.3.190.0070.01016.42
7.3.180.0160.00016.62
7.3.170.0090.00616.68
7.3.160.0130.00316.36
7.3.120.0100.00715.10
7.3.110.0100.01014.92
7.3.100.0000.01314.96
7.3.90.0100.00715.15
7.3.80.0000.01114.92
7.3.70.0030.01414.95
7.3.60.0100.00614.88
7.3.50.0060.00614.88
7.3.40.0040.01214.91
7.3.30.0090.00614.86
7.3.20.0040.00416.59
7.3.10.0030.01016.88
7.3.00.0030.00916.68
7.2.330.0140.00316.63
7.2.320.0120.00516.89
7.2.310.0040.01216.51
7.2.300.0090.00916.82
7.2.290.0120.00816.60
7.2.250.0040.01414.69
7.2.240.0030.01215.29
7.2.230.0000.01115.04
7.2.220.0060.01215.10
7.2.210.0070.00715.39
7.2.200.0090.00915.12
7.2.190.0030.00515.21
7.2.180.0080.00415.17
7.2.170.0120.00315.00
7.2.160.0060.00914.98
7.2.150.0030.00916.67
7.2.140.0040.00816.94
7.2.130.0090.00616.97
7.2.120.0120.00316.70
7.2.110.0080.00416.82
7.2.100.0040.00816.96
7.2.90.0070.00417.11
7.2.80.0000.01317.07
7.2.70.0080.00816.93
7.2.60.0060.00816.99
7.2.50.0000.01516.86
7.2.40.0000.01016.93
7.2.30.0090.00617.13
7.2.20.0030.00717.10
7.2.10.0000.01017.05
7.2.00.0020.01018.24
7.1.330.0070.00715.61
7.1.320.0100.00015.48
7.1.310.0000.01215.78
7.1.300.0120.00015.82
7.1.290.0070.00715.61
7.1.280.0060.00715.86
7.1.270.0070.00715.88
7.1.260.0000.00715.61
7.1.250.0000.01515.87
7.1.200.0090.00315.60
7.1.100.0070.01017.98
7.1.70.0030.00517.31
7.1.60.0070.01119.33
7.1.50.0060.01616.97
7.1.00.0030.08022.37
7.0.200.0000.01116.89
7.0.140.0030.07321.99
7.0.100.0330.07020.02
7.0.90.0430.06319.94
7.0.80.0070.07320.02
7.0.70.0100.07019.89
7.0.60.0030.07720.09
7.0.50.0170.07020.39
7.0.40.0130.07020.11
7.0.30.0030.06020.05
7.0.20.0170.08720.13
7.0.10.0030.09020.13
7.0.00.0130.08320.09
5.6.280.0030.07321.04
5.6.250.0130.04020.64
5.6.240.0100.07320.66
5.6.230.0070.05320.69
5.6.220.0270.06020.63
5.6.210.0100.07720.63
5.6.200.0130.08320.97
5.6.190.0070.08321.03
5.6.180.0130.06321.08
5.6.170.0170.07021.12
5.6.160.0130.08021.08
5.6.150.0130.04020.98
5.6.140.0030.04321.10
5.6.130.0030.06021.02
5.6.120.0000.04720.92
5.6.110.0070.04321.02
5.6.100.0130.03721.09
5.6.90.0030.04321.08
5.6.80.0070.06720.35
5.6.70.0030.04020.41
5.6.60.0100.03320.35
5.6.50.0070.03720.41
5.6.40.0030.04720.27
5.6.30.0170.03020.29
5.6.20.0070.05020.30
5.6.10.0000.04320.32
5.6.00.0030.04020.43
5.5.380.0070.05020.40
5.5.370.0070.08720.39
5.5.360.0000.08320.36
5.5.350.0070.05320.47
5.5.340.0070.07320.91
5.5.330.0070.08020.89
5.5.320.0170.05720.76
5.5.310.0200.07320.86
5.5.300.0070.04020.75
5.5.290.0100.04020.82
5.5.280.0100.04320.95
5.5.270.0100.03320.80
5.5.260.0030.04320.88
5.5.250.0030.04720.55
5.5.240.0070.03720.17
5.5.230.0130.04320.31
5.5.220.0100.07020.32
5.5.210.0030.04020.29
5.5.200.0030.06320.16
5.5.190.0030.04020.29
5.5.180.0030.03720.27
5.5.160.0130.02720.23
5.5.150.0100.03320.09
5.5.140.0030.04020.25
5.5.130.0130.03320.28
5.5.120.0000.04720.16
5.5.110.0030.04020.14
5.5.100.0070.03720.14
5.5.90.0030.04020.02
5.5.80.0000.04320.18
5.5.70.0130.03720.17
5.5.60.0170.02719.98
5.5.50.0000.04020.17
5.5.40.0200.06319.98
5.5.30.0070.04020.16
5.5.20.0030.04320.10
5.5.10.0070.04020.06
5.5.00.0070.03020.03
5.4.450.0100.04019.24
5.4.440.0130.04719.17
5.4.430.0070.04019.49
5.4.420.0000.04019.44
5.4.410.0000.04019.24
5.4.400.0100.03319.04
5.4.390.0030.04019.06
5.4.380.0070.05019.09
5.4.370.0000.04019.14
5.4.360.0030.04319.16
5.4.350.0000.04018.88
5.4.340.0000.04019.04
5.4.320.0100.03319.14
5.4.310.0030.04319.03
5.4.300.0000.04019.04
5.4.290.0030.03719.25
5.4.280.0030.04019.13
5.4.270.0030.03718.90
5.4.260.0030.03719.18
5.4.250.0030.03719.12
5.4.240.0070.03318.89
5.4.230.0000.04019.20
5.4.220.0030.04019.23
5.4.210.0030.04019.21
5.4.200.0030.03719.15
5.4.190.0000.04019.15
5.4.180.0030.03719.20
5.4.170.0070.03018.89
5.4.160.0100.07019.07
5.4.150.0030.07718.83
5.4.140.0070.07316.34
5.4.130.0030.07316.43
5.4.120.0100.05316.33
5.4.110.0070.07716.51
5.4.100.0130.07016.42
5.4.90.0070.07016.43
5.4.80.0070.06316.32
5.4.70.0030.07016.47
5.4.60.0070.04716.49
5.4.50.0070.06716.40
5.4.40.0070.05716.42
5.4.30.0030.06316.46
5.4.20.0100.06316.45
5.4.10.0000.05016.42
5.4.00.0030.07315.78
5.3.290.0070.03314.81
5.3.280.0100.04314.75
5.3.270.0070.03014.66
5.3.260.0070.03714.61
5.3.250.0030.04014.61
5.3.240.0070.07014.76
5.3.230.0100.07314.57
5.3.220.0070.04714.65
5.3.210.0030.08014.57
5.3.200.0130.07014.65
5.3.190.0100.06014.68
5.3.180.0100.03714.70
5.3.170.0100.07014.62
5.3.160.0070.07314.52
5.3.150.0170.06314.60
5.3.140.0070.07314.51
5.3.130.0030.07714.55
5.3.120.0030.08014.60
5.3.110.0030.06014.58
5.3.100.0130.05014.01
5.3.90.0070.05713.97
5.3.80.0000.04314.02
5.3.70.0070.05014.06
5.3.60.0030.07014.08
5.3.50.0070.04013.95
5.3.40.0000.06714.07
5.3.30.0100.06313.92
5.3.20.0030.07013.63
5.3.10.0030.07013.73
5.3.00.0030.06313.64
5.2.170.0030.03711.18
5.2.160.0030.03711.20
5.2.150.0070.06311.20
5.2.140.0030.04311.31
5.2.130.0100.04711.19
5.2.120.0030.06311.24
5.2.110.0000.04711.18
5.2.100.0030.04011.25
5.2.90.0070.06011.18
5.2.80.0230.02311.15
5.2.70.0100.05011.18
5.2.60.0100.05711.17
5.2.50.0030.05011.08
5.2.40.0200.05310.88
5.2.30.0030.05010.93
5.2.20.0030.03711.09
5.2.10.0030.05710.92
5.2.00.0070.05710.80
5.1.60.0100.0509.88
5.1.50.0000.0579.88
5.1.40.0030.05310.00
5.1.30.0000.05710.46
5.1.20.0070.05310.37
5.1.10.0030.05310.17
5.1.00.0100.05010.12
5.0.50.0000.0308.81
5.0.40.0030.0438.81
5.0.30.0030.0538.81
5.0.20.0070.0478.81
5.0.10.0070.0408.81
5.0.00.0070.0708.81
4.4.90.0000.0278.81
4.4.80.0030.0378.81
4.4.70.0070.0278.81
4.4.60.0070.0208.81
4.4.50.0030.0338.81
4.4.40.0000.0538.81
4.4.30.0000.0378.81
4.4.20.0000.0408.81
4.4.10.0030.0378.81
4.4.00.0030.0508.81
4.3.110.0030.0238.81
4.3.100.0030.0278.81
4.3.90.0030.0338.81
4.3.80.0000.0578.81
4.3.70.0000.0338.81
4.3.60.0000.0278.81
4.3.50.0030.0378.81
4.3.40.0130.0278.81
4.3.30.0030.0308.81
4.3.20.0000.0378.81
4.3.10.0000.0378.81
4.3.00.0000.0378.81

preferences:
48.95 ms | 401 KiB | 5 Q