3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { public $var = array(1,2,3); public function __construct($array) { $var = array(1,2,3); 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 $count = 0; /* public function __construct($array) { $var = array(1,2,3); 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(); 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.0200.01017.43
8.3.40.0130.00318.86
8.3.30.0070.00718.85
8.3.20.0030.00518.72
8.3.10.0060.00318.77
8.3.00.0000.00819.25
8.2.180.0120.00316.63
8.2.170.0030.01222.96
8.2.160.0100.00320.43
8.2.150.0050.00224.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0030.00720.87
8.2.110.0060.00320.94
8.2.100.0060.00618.03
8.2.90.0040.00419.09
8.2.80.0000.00817.97
8.2.70.0000.00917.50
8.2.60.0040.00417.93
8.2.50.0040.00417.93
8.2.40.0000.00819.25
8.2.30.0100.00017.79
8.2.20.0040.00417.77
8.2.10.0080.00017.86
8.2.00.0000.00717.89
8.1.280.0070.01425.92
8.1.270.0030.00623.99
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00322.74
8.1.230.0080.00317.82
8.1.220.0000.00817.74
8.1.210.0080.00018.77
8.1.200.0000.00917.22
8.1.190.0050.00317.22
8.1.180.0030.00518.10
8.1.170.0030.00617.62
8.1.160.0040.00418.93
8.1.150.0040.00418.72
8.1.140.0030.00617.48
8.1.130.0050.00219.14
8.1.120.0000.00717.39
8.1.110.0040.00417.48
8.1.100.0030.00417.53
8.1.90.0040.00417.48
8.1.80.0070.00017.43
8.1.70.0030.00317.48
8.1.60.0030.00617.61
8.1.50.0040.00417.41
8.1.40.0030.00617.54
8.1.30.0040.00417.70
8.1.20.0000.00817.56
8.1.10.0000.00817.57
8.1.00.0040.00417.55
8.0.300.0040.00418.77
8.0.290.0060.00316.59
8.0.280.0070.00018.67
8.0.270.0040.00416.92
8.0.260.0040.00416.96
8.0.250.0070.00017.02
8.0.240.0040.00417.00
8.0.230.0040.00417.00
8.0.220.0020.00516.95
8.0.210.0040.00416.97
8.0.200.0040.00417.08
8.0.190.0000.00717.08
8.0.180.0080.00417.08
8.0.170.0000.00816.88
8.0.160.0040.00416.91
8.0.150.0050.00316.91
8.0.140.0030.00616.85
8.0.130.0050.00013.41
8.0.120.0030.00617.01
8.0.110.0040.00417.02
8.0.100.0000.00816.80
8.0.90.0040.00416.93
8.0.80.0060.01117.03
8.0.70.0000.00716.81
8.0.60.0060.00317.10
8.0.50.0000.00817.02
8.0.30.0110.00617.16
8.0.20.0140.00916.99
8.0.10.0050.00317.18
8.0.00.0070.01716.88
7.4.330.0000.00513.02
7.4.320.0070.00016.55
7.4.300.0030.00316.57
7.4.290.0000.00816.56
7.4.280.0030.00616.56
7.4.270.0030.00316.61
7.4.260.0000.00513.23
7.4.250.0050.00316.60
7.4.240.0030.00316.54
7.4.230.0100.00016.51
7.4.220.0090.01016.61
7.4.210.0080.00816.50
7.4.200.0030.00516.45
7.4.190.0030.00416.78
7.4.160.0080.00816.50
7.4.150.0090.00916.54
7.4.140.0060.01716.56
7.4.130.0230.00016.57
7.4.120.0090.01316.55
7.4.110.0120.00616.54
7.4.100.0150.00316.64
7.4.90.0070.01016.84
7.4.80.0120.01219.39
7.4.70.0030.01316.65
7.4.60.0100.00716.50
7.4.50.0000.00516.51
7.4.40.0100.00316.68
7.4.30.0060.01216.53
7.4.00.0100.00715.13
7.3.330.0000.00713.40
7.3.320.0050.00213.32
7.3.310.0000.00716.36
7.3.300.0000.00616.38
7.3.290.0080.00916.34
7.3.280.0080.01116.38
7.3.270.0110.00516.64
7.3.260.0060.01216.48
7.3.250.0110.00716.42
7.3.240.0100.00716.30
7.3.230.0070.01016.31
7.3.210.0100.00616.33
7.3.200.0090.01316.48
7.3.190.0140.00816.45
7.3.180.0150.00316.56
7.3.170.0060.00916.58
7.3.160.0030.01416.55
7.3.120.0090.00714.76
7.3.110.0100.01014.65
7.3.100.0040.01214.70
7.3.90.0140.00414.84
7.3.80.0140.00015.00
7.3.70.0040.01514.99
7.3.60.0030.01514.90
7.3.50.0080.00814.94
7.3.40.0000.01614.68
7.3.30.0030.00614.92
7.3.20.0040.00816.81
7.3.10.0060.00616.64
7.3.00.0110.00416.68
7.2.330.0070.01016.41
7.2.320.0010.02516.75
7.2.310.0090.00916.61
7.2.300.0080.01516.72
7.2.290.0060.01216.82
7.2.250.0040.01514.65
7.2.240.0140.00714.81
7.2.230.0140.00714.64
7.2.220.0090.00615.25
7.2.210.0070.01014.83
7.2.200.0070.01114.87
7.2.190.0030.01214.92
7.2.180.0090.00615.16
7.2.170.0090.00615.08
7.2.60.0030.00916.73
7.2.50.0060.00316.96
7.2.00.0030.01019.47
7.1.330.0070.00715.54
7.1.320.0090.00915.66
7.1.310.0130.00315.40
7.1.300.0040.00815.79
7.1.290.0030.00915.64
7.1.280.0090.00615.60
7.1.270.0000.00915.72
7.1.260.0070.00715.70
7.1.200.0040.01115.89
7.1.100.0550.00915.68
7.1.70.0030.00517.13
7.1.60.0100.01319.30
7.1.50.0040.01416.55
7.1.00.0000.08022.37
7.0.200.0000.00716.50
7.0.140.0000.07321.92
7.0.120.0000.07722.04
7.0.60.0300.07019.89
7.0.50.0170.07317.89
7.0.40.0170.08020.10
7.0.30.0130.04320.20
7.0.20.0070.08020.23
7.0.10.0100.04320.01
7.0.00.0030.04320.01
5.6.280.0130.06020.86
5.6.210.0070.06720.52
5.6.200.0070.04018.19
5.6.190.0170.07020.41
5.6.180.0030.09020.63
5.6.170.0070.08720.76
5.6.160.0030.04320.46
5.6.150.0070.07320.37
5.6.140.0070.04720.41
5.6.130.0030.04320.32
5.6.120.0070.05720.43
5.6.110.0030.09020.43
5.6.100.0130.05020.29
5.6.90.0170.08020.32
5.6.80.0070.08019.88
5.6.70.0070.04319.71
5.6.60.0070.08319.55
5.6.50.0030.08719.82
5.6.40.0070.06319.72
5.6.30.0030.08719.68
5.6.20.0130.06019.87
5.6.10.0030.08719.79
5.6.00.0070.08019.75
5.5.350.0100.07720.50
5.5.340.0070.07017.99
5.5.330.0130.06020.31
5.5.320.0070.08020.41
5.5.310.0200.03020.21
5.5.300.0030.06720.21
5.5.290.0070.08020.20
5.5.280.0170.06020.24
5.5.270.0030.08320.03
5.5.260.0070.08720.20
5.5.250.0000.05320.11
5.5.240.0030.05319.59
5.5.230.0030.06719.67
5.5.220.0070.06019.68
5.5.210.0100.06319.51
5.5.200.0070.06319.33
5.5.190.0000.06019.49
5.5.180.0070.04019.47
5.5.160.0100.04019.32
5.5.150.0100.08019.38
5.5.140.0070.08319.65
5.5.130.0200.07319.54
5.5.120.0100.08019.48
5.5.110.0000.05319.46
5.5.100.0100.03319.46
5.5.90.0170.07019.42
5.5.80.0000.07019.45
5.5.70.0100.04319.39
5.5.60.0030.04019.44
5.5.50.0030.04019.36
5.5.40.0100.07719.43
5.5.30.0000.04319.46
5.5.20.0070.08719.51
5.5.10.0030.07019.51
5.5.00.0030.04319.30
5.4.450.0070.07719.45
5.4.440.0000.08719.33
5.4.430.0070.05319.56
5.4.420.0070.04719.47
5.4.410.0070.08019.28
5.4.400.0000.04319.16
5.4.390.0030.06719.15
5.4.380.0030.07019.00
5.4.370.0130.07019.15
5.4.360.0030.06319.24
5.4.350.0070.07718.85
5.4.340.0130.07319.14
5.4.320.0100.05319.16
5.4.310.0100.07319.01
5.4.300.0030.04018.86
5.4.290.0130.06718.97
5.4.280.0070.08019.14
5.4.270.0170.06019.24
5.4.260.0030.05019.15
5.4.250.0070.03318.92
5.4.240.0030.04019.15
5.4.230.0100.06719.23
5.4.220.0170.05718.88
5.4.210.0100.03319.23
5.4.200.0070.05319.23
5.4.190.0130.06018.96
5.4.180.0070.07319.22
5.4.170.0070.04019.19
5.4.160.0100.05319.13
5.4.150.0030.05019.10
5.4.140.0030.07316.35
5.4.130.0070.04316.46
5.4.120.0070.03316.34
5.4.110.0000.06716.53
5.4.100.0000.07316.52
5.4.90.0100.06716.44
5.4.80.0070.03316.52
5.4.70.0100.07316.37
5.4.60.0070.05716.38
5.4.50.0000.07716.64
5.4.40.0070.07316.27
5.4.30.0000.07016.64
5.4.20.0030.06316.36
5.4.10.0030.07716.27
5.4.00.0070.04015.95
5.3.290.0030.08014.75
5.3.280.0030.07314.63
5.3.270.0170.06714.59
5.3.260.0100.03314.66
5.3.250.0000.07314.65
5.3.240.0030.05014.69
5.3.230.0130.03714.64
5.3.220.0070.08014.61
5.3.210.0030.04014.73
5.3.200.0030.03714.67
5.3.190.0000.04014.61
5.3.180.0100.03014.61
5.3.170.0070.05014.61
5.3.160.0000.04014.64
5.3.150.0070.06714.58
5.3.140.0030.07714.64
5.3.130.0100.06014.64
5.3.120.0030.07314.60
5.3.110.0030.07714.55
5.3.100.0030.05713.97
5.3.90.0000.05014.08
5.3.80.0000.06014.11
5.3.70.0030.03714.02
5.3.60.0030.06013.98
5.3.50.0070.07014.12
5.3.40.0030.04013.85
5.3.30.0100.06713.88
5.3.20.0070.07013.65
5.3.10.0030.07713.68
5.3.00.0030.04013.57
5.2.170.0000.06011.22
5.2.160.0100.06011.31
5.2.150.0030.05711.31
5.2.140.0070.06311.22
5.2.130.0030.05011.12
5.2.120.0030.03711.12
5.2.110.0000.07011.17
5.2.100.0100.02311.13
5.2.90.0000.03011.07
5.2.80.0030.02711.00
5.2.70.0100.02711.29
5.2.60.0070.03310.96
5.2.50.0030.04711.09
5.2.40.0030.03310.96
5.2.30.0030.03711.00
5.2.20.0100.05311.02
5.2.10.0100.05010.76
5.2.00.0000.04310.79
5.1.60.0070.05010.00
5.1.50.0070.05010.17
5.1.40.0030.04310.06
5.1.30.0030.03010.42
5.1.20.0000.03310.38
5.1.10.0070.05310.15
5.1.00.0000.02710.10
5.0.50.0030.0238.59
5.0.40.0030.0438.59
5.0.30.0030.0608.22
5.0.20.0030.0408.36
5.0.10.0070.0408.16
5.0.00.0000.0708.23
4.4.90.0000.0176.35
4.4.80.0100.0136.35
4.4.70.0000.0406.35
4.4.60.0070.0306.35
4.4.50.0000.0176.35
4.4.40.0000.0376.35
4.4.30.0000.0176.35
4.4.20.0000.0176.35
4.4.10.0000.0206.35
4.4.00.0000.0376.35
4.3.110.0030.0176.35
4.3.100.0000.0206.35
4.3.90.0030.0276.35
4.3.80.0000.0536.35
4.3.70.0000.0306.35
4.3.60.0030.0206.35
4.3.50.0000.0176.35
4.3.40.0000.0236.35
4.3.30.0030.0236.35
4.3.20.0030.0206.35
4.3.10.0030.0176.35
4.3.00.0000.0176.35

preferences:
46.29 ms | 401 KiB | 5 Q