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('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) {$coll->getIterator($var); 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.0120.00318.37
8.3.50.0030.01521.99
8.3.40.0150.00018.70
8.3.30.0100.00718.96
8.3.20.0040.00420.20
8.3.10.0080.00021.92
8.3.00.0040.00422.51
8.2.180.0070.01417.00
8.2.170.0120.00322.96
8.2.160.0100.01021.12
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0030.00519.36
8.2.110.0100.00020.98
8.2.100.0080.00417.72
8.2.90.0050.00319.17
8.2.80.0000.00817.97
8.2.70.0000.00817.63
8.2.60.0000.00818.04
8.2.50.0040.00718.10
8.2.40.0030.00718.09
8.2.30.0040.00418.16
8.2.20.0040.00417.77
8.2.10.0000.00819.50
8.2.00.0040.00417.71
8.1.280.0060.00925.92
8.1.270.0060.00323.83
8.1.260.0080.00026.35
8.1.250.0090.00028.09
8.1.240.0100.00022.66
8.1.230.0070.00417.70
8.1.220.0050.00317.78
8.1.210.0090.00318.77
8.1.200.0030.00617.23
8.1.190.0030.00517.23
8.1.180.0030.00618.10
8.1.170.0090.00018.66
8.1.160.0030.00622.06
8.1.150.0000.00818.61
8.1.140.0060.00317.48
8.1.130.0040.00417.84
8.1.120.0000.00717.52
8.1.110.0050.00517.49
8.1.100.0030.00517.42
8.1.90.0000.00717.34
8.1.80.0000.00717.52
8.1.70.0000.00817.43
8.1.60.0050.00317.48
8.1.50.0030.00517.52
8.1.40.0000.00817.56
8.1.30.0050.00317.66
8.1.20.0080.00017.70
8.1.10.0000.00817.64
8.1.00.0080.00017.55
8.0.300.0070.00318.77
8.0.290.0060.00316.75
8.0.280.0030.00518.54
8.0.270.0070.00017.14
8.0.260.0030.00316.81
8.0.250.0040.00416.95
8.0.240.0050.00216.93
8.0.230.0030.00317.06
8.0.220.0000.00716.86
8.0.210.0040.00417.03
8.0.200.0000.00617.00
8.0.190.0050.00217.04
8.0.180.0040.00416.91
8.0.170.0040.00417.05
8.0.160.0030.00517.04
8.0.150.0030.00316.91
8.0.140.0000.00816.92
8.0.130.0030.00513.47
8.0.120.0000.00816.97
8.0.110.0000.00716.89
8.0.100.0050.00216.93
8.0.90.0070.00016.82
8.0.80.0090.00616.92
8.0.70.0040.00416.99
8.0.60.0070.00017.00
8.0.50.0070.00016.85
8.0.30.0110.01217.10
8.0.20.0110.01017.45
8.0.10.0000.00717.05
8.0.00.0050.01216.80
7.4.330.0020.00215.09
7.4.320.0000.00616.53
7.4.300.0040.00416.62
7.4.290.0040.00416.54
7.4.280.0030.00316.66
7.4.270.0000.00716.59
7.4.260.0030.00316.54
7.4.250.0000.00716.45
7.4.240.0060.00116.53
7.4.230.0000.00716.34
7.4.220.0140.00716.54
7.4.210.0090.00516.65
7.4.200.0070.00016.52
7.4.190.0040.00416.70
7.4.160.0110.00416.57
7.4.150.0030.01517.40
7.4.140.0140.00617.86
7.4.130.0130.00816.63
7.4.120.0050.01116.60
7.4.110.0130.00416.64
7.4.100.0070.01116.52
7.4.90.0110.01016.62
7.4.80.0190.00516.55
7.4.70.0160.00016.63
7.4.60.0090.00916.64
7.4.50.0050.00016.45
7.4.40.0180.00022.77
7.4.30.0070.01416.51
7.4.00.0070.00314.78
7.3.330.0000.00613.39
7.3.320.0000.00513.30
7.3.310.0000.00716.39
7.3.300.0030.00316.35
7.3.290.0080.01216.45
7.3.280.0110.00916.41
7.3.270.0150.00317.40
7.3.260.0090.01316.73
7.3.250.0100.00716.54
7.3.240.0120.01216.57
7.3.230.0120.00616.45
7.3.210.0060.01216.40
7.3.200.0090.01519.39
7.3.190.0060.01216.66
7.3.180.0070.01116.53
7.3.170.0120.00416.36
7.3.160.0120.00316.56
7.3.120.0150.00015.00
7.3.10.0060.00616.71
7.3.00.0030.01016.51
7.2.330.0100.00716.66
7.2.320.0070.01716.47
7.2.310.0000.01916.87
7.2.300.0100.00716.71
7.2.290.0150.00916.62
7.2.130.0030.01016.89
7.2.120.0090.00617.06
7.2.110.0060.00917.04
7.2.100.0000.01217.15
7.2.90.0030.01016.93
7.2.80.0070.00317.03
7.2.70.0030.00616.86
7.2.60.0070.00716.96
7.2.50.0000.01316.86
7.2.40.0000.01217.06
7.2.30.0060.01216.98
7.2.20.0060.00917.06
7.2.10.0030.01317.06
7.2.00.0030.01218.16
7.1.250.0130.00015.96
7.1.200.0140.00415.81
7.1.100.0060.00918.11
7.1.70.0060.00616.95
7.1.60.0090.01619.82
7.1.50.0000.01317.06
7.1.00.0130.06322.43
7.0.200.0070.00716.49
7.0.140.0030.07322.01
7.0.100.0070.07019.91
7.0.90.0030.04719.93
7.0.80.0030.04719.95
7.0.70.0000.05320.16
7.0.60.0030.06320.00
7.0.50.0130.07320.36
7.0.40.0030.08320.06
7.0.30.0030.08720.10
7.0.20.0100.07720.09
7.0.10.0170.06320.02
7.0.00.0200.06720.03
5.6.280.0070.06721.08
5.6.250.0070.04020.54
5.6.240.0000.05020.69
5.6.230.0030.03720.63
5.6.220.0000.05020.50
5.6.210.0030.08020.77
5.6.200.0170.08021.09
5.6.190.0070.08021.11
5.6.180.0070.07320.96
5.6.170.0170.07721.11
5.6.160.0000.09320.95
5.6.150.0070.08721.04
5.6.140.0030.07021.13
5.6.130.0130.08320.99
5.6.120.0100.05320.96
5.6.110.0130.08021.05
5.6.100.0070.08721.02
5.6.90.0070.08320.99
5.6.80.0130.06720.36
5.6.70.0170.07720.55
5.6.60.0000.06020.41
5.6.50.0030.07020.39
5.6.40.0070.07720.46
5.6.30.0030.06320.41
5.6.20.0100.05720.46
5.6.10.0030.08720.30
5.6.00.0100.06020.34
5.5.380.0030.04020.36
5.5.370.0070.04020.41
5.5.360.0100.03720.42
5.5.350.0000.04720.38
5.5.340.0170.06720.80
5.5.330.0100.05020.80
5.5.320.0030.06320.80
5.5.310.0100.07320.80
5.5.300.0070.08020.91
5.5.290.0070.09020.83
5.5.280.0070.07020.84
5.5.270.0070.08020.79
5.5.260.0030.05020.92
5.5.250.0030.08320.65
5.5.240.0130.07320.21
5.5.230.0000.07320.26
5.5.220.0100.07020.16
5.5.210.0100.08020.21
5.5.200.0100.04320.08
5.5.190.0100.05020.22
5.5.180.0030.05320.24
5.5.160.0100.07720.13
5.5.150.0230.05320.15
5.5.140.0030.08020.18
5.5.130.0070.07720.28
5.5.120.0200.07720.18
5.5.110.0070.06020.25
5.5.100.0000.08320.07
5.5.90.0130.05720.17
5.5.80.0100.07020.17
5.5.70.0070.08020.11
5.5.60.0030.06720.04
5.5.50.0070.07720.06
5.5.40.0200.06720.03
5.5.30.0170.07020.09
5.5.20.0130.07020.05
5.5.10.0100.07719.98
5.5.00.0000.08020.09
5.4.450.0100.08019.35
5.4.440.0100.07319.36
5.4.430.0030.08719.46
5.4.420.0070.08019.48
5.4.410.0070.06319.33
5.4.400.0070.06718.91
5.4.390.0070.08318.95
5.4.380.0030.07719.23
5.4.370.0070.07719.12
5.4.360.0100.07019.09
5.4.350.0100.06319.10
5.4.340.0100.07319.23
5.4.320.0030.07719.05
5.4.310.0100.07718.95
5.4.300.0100.07318.94
5.4.290.0070.03718.90
5.4.280.0030.08018.88
5.4.270.0070.07719.09
5.4.260.0200.04719.03
5.4.250.0070.07719.17
5.4.240.0130.06719.15
5.4.230.0200.07319.09
5.4.220.0030.08018.84
5.4.210.0030.08019.08
5.4.200.0070.07718.83
5.4.190.0000.07319.22
5.4.180.0070.07319.02
5.4.170.0130.07719.22
5.4.160.0100.04719.16
5.4.150.0000.06018.88
5.4.140.0030.07016.44
5.4.130.0030.07316.29
5.4.120.0100.06716.28
5.4.110.0030.04016.50
5.4.100.0130.06016.42
5.4.90.0000.04016.49
5.4.80.0070.07316.46
5.4.70.0130.06316.50
5.4.60.0070.03716.25
5.4.50.0030.03716.45
5.4.40.0030.07316.53
5.4.30.0030.06716.43
5.4.20.0030.03716.36
5.4.10.0000.05316.29
5.4.00.0130.06715.73
5.3.290.0030.07014.79
5.3.280.0130.06714.68
5.3.270.0030.07014.69
5.3.260.0070.07714.68
5.3.250.0070.07314.61
5.3.240.0030.07714.74
5.3.230.0030.06014.54
5.3.220.0100.07314.57
5.3.210.0030.07714.56
5.3.200.0100.06314.69
5.3.190.0100.03314.55
5.3.180.0130.07014.67
5.3.170.0170.06714.64
5.3.160.0030.07314.57
5.3.150.0070.07014.70
5.3.140.0030.08014.50
5.3.130.0070.07714.60
5.3.120.0100.05314.58
5.3.110.0030.03314.62
5.3.100.0100.06714.02
5.3.90.0000.05013.96
5.3.80.0030.06014.17
5.3.70.0100.05313.93
5.3.60.0030.07714.02
5.3.50.0000.03313.99
5.3.40.0070.06313.85
5.3.30.0070.06013.94
5.3.20.0030.07713.73
5.3.10.0030.07313.76
5.3.00.0070.07313.55
5.2.170.0070.05712.61
5.2.160.0070.06712.61
5.2.150.0030.04012.61
5.2.140.0100.06012.61
5.2.130.0070.05712.61
5.2.120.0100.06012.61
5.2.110.0070.06012.61
5.2.100.0030.06712.61
5.2.90.0030.06712.61
5.2.80.0030.05312.61
5.2.70.0030.05712.61
5.2.60.0070.05712.61
5.2.50.0100.06012.61
5.2.40.0070.06012.61
5.2.30.0070.05312.61
5.2.20.0030.06312.61
5.2.10.0030.06012.61
5.2.00.0070.05712.61
5.1.60.0070.04312.61
5.1.50.0030.03012.61
5.1.40.0070.05012.61
5.1.30.0030.05712.61
5.1.20.0000.05012.61
5.1.10.0070.05012.61
5.1.00.0030.05012.61
5.0.50.0100.04012.61
5.0.40.0030.04312.61
5.0.30.0070.06312.61
5.0.20.0070.04312.61
5.0.10.0100.03012.61
5.0.00.0030.06312.61
4.4.90.0030.03012.61
4.4.80.0000.03712.61
4.4.70.0070.03012.61
4.4.60.0070.03012.61
4.4.50.0030.03712.61
4.4.40.0030.05012.61
4.4.30.0030.02712.61
4.4.20.0100.02712.61
4.4.10.0030.04012.61
4.4.00.0030.03712.61
4.3.110.0000.03312.61
4.3.100.0070.03012.61
4.3.90.0030.03312.61
4.3.80.0070.04012.61
4.3.70.0030.03012.61
4.3.60.0100.02312.61
4.3.50.0000.03312.61
4.3.40.0070.04712.61
4.3.30.0000.02312.61
4.3.20.0000.02712.61
4.3.10.0000.03712.61
4.3.00.0030.03312.61

preferences:
65.19 ms | 401 KiB | 5 Q