3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { public $var = array(1,2,3); 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 $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.60.0080.00818.56
8.3.50.0160.00516.46
8.3.40.0120.00618.71
8.3.30.0110.00718.85
8.3.20.0080.00018.60
8.3.10.0060.00318.77
8.3.00.0080.00417.50
8.2.180.0140.00718.28
8.2.170.0110.00422.96
8.2.160.0070.00718.89
8.2.150.0130.00625.66
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0030.00921.05
8.2.110.0000.00919.38
8.2.100.0060.00617.97
8.2.90.0040.00417.88
8.2.80.0060.00317.97
8.2.70.0030.00717.93
8.2.60.0090.00018.03
8.2.50.0080.00018.10
8.2.40.0030.00620.36
8.2.30.0040.00419.15
8.2.20.0050.00517.58
8.2.10.0000.00717.64
8.2.00.0040.00417.75
8.1.280.0120.00825.92
8.1.270.0030.00524.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00619.01
8.1.230.0070.00317.70
8.1.220.0000.00917.76
8.1.210.0030.00618.77
8.1.200.0100.00017.48
8.1.190.0080.00017.23
8.1.180.0040.00418.10
8.1.170.0080.00018.55
8.1.160.0040.00418.85
8.1.150.0000.00718.92
8.1.140.0070.00017.55
8.1.130.0070.00017.48
8.1.120.0070.00417.51
8.1.110.0000.00817.48
8.1.100.0050.00217.38
8.1.90.0000.00717.50
8.1.80.0040.00417.51
8.1.70.0070.00017.49
8.1.60.0030.00617.49
8.1.50.0030.00617.37
8.1.40.0030.00617.50
8.1.30.0000.00917.56
8.1.20.0050.00317.57
8.1.10.0040.00417.54
8.1.00.0080.00017.55
8.0.300.0070.00018.77
8.0.290.0030.00516.75
8.0.280.0000.00718.38
8.0.270.0000.00717.36
8.0.260.0070.00016.95
8.0.250.0070.00017.07
8.0.240.0040.00417.07
8.0.230.0080.00016.94
8.0.220.0030.00317.05
8.0.210.0050.00216.98
8.0.200.0050.00217.05
8.0.190.0040.00416.87
8.0.180.0040.00417.03
8.0.170.0050.00316.92
8.0.160.0030.00516.98
8.0.150.0080.00016.92
8.0.140.0030.00516.89
8.0.130.0030.00313.40
8.0.120.0050.00316.98
8.0.110.0070.00017.00
8.0.100.0000.00716.85
8.0.90.0040.00417.00
8.0.80.0110.00616.95
8.0.70.0070.00016.87
8.0.60.0030.00616.83
8.0.50.0030.00716.99
8.0.30.0070.00716.98
8.0.20.0070.01217.23
8.0.10.0000.00817.00
8.0.00.0040.01416.96
7.4.330.0050.00013.00
7.4.320.0030.00316.54
7.4.300.0030.00316.59
7.4.290.0030.00316.66
7.4.280.0000.00716.63
7.4.270.0030.00316.64
7.4.260.0050.00013.31
7.4.250.0040.00416.52
7.4.240.0050.00316.54
7.4.230.0000.00716.43
7.4.220.0110.00816.62
7.4.210.0060.01216.54
7.4.200.0030.00316.34
7.4.190.0000.00816.49
7.4.160.0120.00616.57
7.4.150.0090.00916.46
7.4.140.0140.00517.86
7.4.130.0130.00616.58
7.4.120.0130.00616.53
7.4.110.0000.01816.75
7.4.100.0150.00616.61
7.4.90.0120.00616.71
7.4.80.0220.00019.39
7.4.70.0090.00616.38
7.4.60.0060.01116.67
7.4.50.0030.00616.53
7.4.40.0100.00716.57
7.4.30.0090.01216.45
7.4.00.0000.01414.86
7.3.330.0030.00313.36
7.3.320.0050.00213.42
7.3.310.0040.00416.46
7.3.300.0040.00416.43
7.3.290.0090.00616.44
7.3.280.0130.00716.45
7.3.270.0100.00716.60
7.3.260.0080.00816.45
7.3.240.0140.00316.45
7.3.230.0100.00716.45
7.3.210.0060.01816.53
7.3.200.0130.00416.59
7.3.190.0110.00516.46
7.3.180.0100.01316.38
7.3.170.0070.01116.36
7.3.160.0120.00316.64
7.3.120.0060.00915.02
7.2.330.0120.00616.58
7.2.320.0060.01116.73
7.2.310.0140.00316.59
7.2.300.0060.01216.41
7.2.290.0100.00716.83
7.2.60.0100.00316.93
7.2.50.0040.01116.94
7.2.00.0030.00919.10
7.1.200.0090.00315.73
7.1.100.0070.00718.01
7.1.70.0060.00917.25
7.1.60.0070.01719.25
7.1.50.0150.00616.99
7.1.00.0070.07022.37
7.0.200.0000.00816.84
7.0.140.0000.07722.00
7.0.120.0070.07022.01
7.0.60.0130.06319.97
7.0.50.0070.04017.88
7.0.40.0130.06720.09
7.0.30.0430.06020.26
7.0.20.0230.07720.15
7.0.10.0270.07020.26
7.0.00.0100.04720.05
5.6.280.0000.07320.92
5.6.210.0130.04320.68
5.6.200.0000.04318.16
5.6.190.0070.04020.60
5.6.180.0300.07320.36
5.6.170.0200.04720.44
5.6.160.0070.04020.54
5.6.150.0100.07018.18
5.6.140.0070.08718.23
5.6.130.0030.06718.26
5.6.120.0070.04020.96
5.6.110.0100.08021.00
5.6.100.0130.05721.09
5.6.90.0070.06020.98
5.6.80.0070.08320.40
5.6.70.1630.03320.39
5.5.350.0170.05720.34
5.5.340.0030.06717.98
5.5.330.0100.03720.35
5.5.320.0170.08320.57
5.5.310.0330.08020.35
5.5.300.0070.05717.95
5.5.290.0130.07318.04
5.5.280.0130.07720.90
5.5.270.0100.03320.88
5.5.260.0070.04320.80
5.5.250.0000.08720.70
5.5.240.0100.08020.27
5.4.450.0000.04719.59
5.4.440.0070.06319.56
5.4.430.0230.06719.56
5.4.420.0100.07719.40
5.4.410.0130.04019.34
5.4.400.0000.04319.15
5.4.390.0070.06318.85
5.4.380.0000.04719.14
5.4.370.0030.08019.12
5.4.360.0130.03318.86
5.4.350.0030.04018.85
5.4.340.0130.04719.24
5.4.320.0100.04719.24
5.4.310.0130.06318.95
5.4.300.0070.03718.91
5.4.290.0000.04318.87
5.4.280.0100.07719.07
5.4.270.0100.03719.07
5.4.260.0030.08019.14
5.4.250.0070.04018.86
5.4.240.0100.07718.85
5.4.230.0070.03719.24
5.4.220.0170.07019.00
5.4.210.0070.07719.23
5.4.200.0170.06719.14
5.4.190.0070.03719.14
5.4.180.0130.04019.14
5.4.170.0130.06719.14
5.4.160.0100.04719.21
5.4.150.0070.06319.21
5.4.140.0170.04016.32
5.4.130.0030.07016.50
5.4.120.0030.05016.41
5.4.110.0070.07716.49
5.4.100.0130.06716.29
5.4.90.0030.07316.47
5.4.80.0070.06716.37
5.4.70.0030.06316.40
5.4.60.0030.07716.27
5.4.50.0100.05716.45
5.4.40.0030.03716.29
5.4.30.0100.05016.26
5.4.20.0000.05316.50
5.4.10.0000.08316.40
5.4.00.0030.04715.77
5.3.290.0030.05014.68
5.3.280.0100.06014.77
5.3.270.0070.07314.65
5.3.260.0130.05714.68
5.3.250.0070.05014.67
5.3.240.0070.04014.64
5.3.230.0030.07314.69
5.3.220.0130.04314.50
5.3.210.0100.04014.51
5.3.200.0030.05014.47
5.3.190.0070.08014.60
5.3.180.0030.06714.61
5.3.170.0070.04714.66
5.3.160.0100.04714.50
5.3.150.0100.07014.59
5.3.140.0000.05014.50
5.3.130.0030.04014.60
5.3.120.0030.06714.56
5.3.110.0030.05714.59
5.3.100.0030.07714.11
5.3.90.0100.07014.04
5.3.80.0100.06014.19
5.3.70.0070.06714.05
5.3.60.0030.07714.18
5.3.50.0070.08014.02
5.3.40.0000.08013.97
5.3.30.0070.05714.08
5.3.20.0070.07713.73
5.3.10.0200.03713.71
5.3.00.0070.07313.81
5.2.170.0030.06311.13
5.2.160.0130.04711.23
5.2.150.0000.05711.17
5.2.140.0000.04711.22
5.2.130.0000.04311.28
5.2.120.0070.04311.08
5.2.110.0030.04011.08
5.2.100.0000.03711.11
5.2.90.0030.02711.05
5.2.80.0030.05711.13
5.2.70.0070.06311.09
5.2.60.0030.02711.23
5.2.50.0000.07011.02
5.2.40.0100.03311.18
5.2.30.0100.04311.16
5.2.20.0130.05711.04
5.2.10.0030.06010.96
5.2.00.0030.03710.74
5.1.60.0000.04010.11
5.1.50.0030.0239.93
5.1.40.0070.02010.07
5.1.30.0030.03310.37
5.1.20.0070.02310.39
5.1.10.0070.05010.00
5.1.00.0000.02710.05
5.0.50.0000.0238.48
5.0.40.0030.0238.34
5.0.30.0030.0608.16
5.0.20.0000.0478.37
5.0.10.0030.0438.11
5.0.00.0000.0338.14
4.4.90.0000.0237.88
4.4.80.0000.0177.88
4.4.70.0000.0277.88
4.4.60.0030.0307.88
4.4.50.0000.0207.88
4.4.40.0000.0307.88
4.4.30.0000.0177.88
4.4.20.0000.0407.88
4.4.10.0000.0177.88
4.4.00.0030.0377.88
4.3.110.0000.0377.88
4.3.100.0000.0207.88
4.3.90.0030.0207.88
4.3.80.0000.0337.88
4.3.70.0030.0237.88
4.3.60.0030.0337.88
4.3.50.0000.0337.88
4.3.40.0030.0507.88
4.3.30.0000.0207.88
4.3.20.0000.0377.88
4.3.10.0000.0307.88
4.3.00.0000.0377.88

preferences:
49.69 ms | 401 KiB | 5 Q