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 static $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(parent::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.0140.00418.41
8.3.50.0070.00822.06
8.3.40.0120.00918.96
8.3.30.0110.00419.09
8.3.20.0040.00420.20
8.3.10.0040.00422.04
8.3.00.0040.00422.38
8.2.180.0070.00716.63
8.2.170.0090.00622.96
8.2.160.0110.00420.98
8.2.150.0000.01024.18
8.2.140.0050.00324.66
8.2.130.0050.00326.16
8.2.120.0030.00517.75
8.2.110.0060.00322.25
8.2.100.0040.00819.64
8.2.90.0040.00419.09
8.2.80.0030.00517.97
8.2.70.0030.00617.63
8.2.60.0050.00317.80
8.2.50.0060.00318.07
8.2.40.0050.00317.91
8.2.30.0040.00418.00
8.2.20.0080.00017.68
8.2.10.0080.00019.66
8.2.00.0050.00217.70
8.1.280.0030.01025.92
8.1.270.0080.00022.06
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00323.84
8.1.230.0030.00719.14
8.1.220.0080.00017.74
8.1.210.0090.00018.77
8.1.200.0030.00617.22
8.1.190.0050.00317.54
8.1.180.0040.00418.10
8.1.170.0050.00318.56
8.1.160.0050.00322.02
8.1.150.0030.00518.62
8.1.140.0000.00717.38
8.1.130.0030.00517.84
8.1.120.0040.00417.41
8.1.110.0070.00317.39
8.1.100.0000.00717.48
8.1.90.0040.00417.36
8.1.80.0050.00217.51
8.1.70.0030.00317.45
8.1.60.0050.00517.54
8.1.50.0040.00417.40
8.1.40.0040.00417.39
8.1.30.0000.00717.56
8.1.20.0030.00517.73
8.1.10.0040.00417.53
8.1.00.0020.00517.51
8.0.300.0040.00418.77
8.0.290.0040.00417.05
8.0.280.0040.00418.54
8.0.270.0070.00017.18
8.0.260.0030.00316.91
8.0.250.0040.00417.01
8.0.240.0040.00416.95
8.0.230.0070.00017.06
8.0.220.0030.00316.98
8.0.210.0080.00016.98
8.0.200.0040.00417.05
8.0.190.0030.00617.05
8.0.180.0040.00417.02
8.0.170.0040.00416.98
8.0.160.0040.00417.05
8.0.150.0000.00716.90
8.0.140.0000.00716.95
8.0.130.0000.00613.41
8.0.120.0060.00316.93
8.0.110.0030.00516.99
8.0.100.0070.00016.88
8.0.90.0000.00717.05
8.0.80.0090.00617.05
8.0.70.0030.00616.94
8.0.60.0040.00416.91
8.0.50.0040.00416.86
8.0.30.0080.01216.99
8.0.20.0110.00917.40
8.0.10.0040.00417.11
8.0.00.0120.00516.79
7.4.330.0000.00515.00
7.4.320.0050.00316.47
7.4.300.0030.00316.57
7.4.290.0040.00416.46
7.4.280.0000.00816.39
7.4.270.0030.00316.62
7.4.260.0070.00016.47
7.4.250.0090.00016.54
7.4.240.0020.00516.39
7.4.230.0070.00016.69
7.4.220.0130.00416.55
7.4.210.0050.00916.54
7.4.200.0030.00316.56
7.4.190.0030.00316.64
7.4.160.0060.00916.72
7.4.150.0100.01017.40
7.4.140.0130.00517.86
7.4.130.0070.01316.58
7.4.120.0090.00816.58
7.4.110.0070.01116.54
7.4.100.0030.01716.64
7.4.90.0030.01516.67
7.4.80.0070.01019.39
7.4.70.0070.01016.45
7.4.60.0110.00616.43
7.4.50.0050.00316.41
7.4.40.0100.00722.77
7.4.30.0100.00616.60
7.4.00.0110.00715.08
7.3.330.0050.00013.35
7.3.320.0000.00613.32
7.3.310.0050.00216.36
7.3.300.0000.00716.44
7.3.290.0120.00316.39
7.3.280.0110.00716.38
7.3.270.0110.00617.40
7.3.260.0100.00716.28
7.3.250.0050.01216.33
7.3.240.0170.00016.55
7.3.230.0130.00316.39
7.3.210.0090.00916.44
7.3.200.0060.01219.39
7.3.190.0060.01016.31
7.3.180.0100.00616.43
7.3.170.0110.00916.57
7.3.160.0070.01016.50
7.3.120.0100.00715.05
7.3.110.0110.00414.82
7.3.100.0120.00314.85
7.3.90.0030.01014.80
7.3.80.0080.00814.89
7.3.70.0030.01014.69
7.3.60.0000.01214.88
7.3.50.0060.00915.06
7.3.40.0000.01114.90
7.3.30.0040.01214.61
7.3.20.0090.00616.63
7.3.10.0030.01416.68
7.3.00.0030.00716.66
7.2.330.0090.00916.64
7.2.320.0080.01516.58
7.2.310.0120.00616.56
7.2.300.0090.00616.73
7.2.290.0060.01016.47
7.2.240.0070.01014.91
7.2.230.0140.00314.62
7.2.220.0040.00814.83
7.2.210.0070.01115.07
7.2.200.0030.01314.79
7.2.190.0080.00815.10
7.2.180.0070.00714.76
7.2.170.0140.00415.00
7.2.160.0070.01014.98
7.2.150.0070.01116.95
7.2.140.0040.00816.96
7.2.130.0000.01816.88
7.2.120.0110.00416.91
7.2.110.0060.01017.02
7.2.100.0100.00716.86
7.2.90.0030.00716.89
7.2.80.0090.00616.95
7.2.70.0060.00916.91
7.2.60.0180.00416.87
7.2.50.0160.00016.73
7.2.40.0080.00816.89
7.2.30.0070.01016.50
7.2.20.0060.00617.08
7.2.10.0070.01116.80
7.2.00.0080.00416.80
7.1.330.0000.01615.84
7.1.320.0120.00315.43
7.1.310.0030.00715.43
7.1.300.0000.00915.84
7.1.290.0070.00715.43
7.1.280.0030.01015.67
7.1.270.0030.01415.68
7.1.260.0110.00315.78
7.1.250.0090.00315.84
7.1.200.0090.00315.86
7.1.100.0030.01018.00
7.1.70.0080.00416.92
7.1.60.0160.01019.82
7.1.50.0070.01417.02
7.1.00.0100.07022.57
7.0.200.0030.00516.54
7.0.140.0030.07322.21
7.0.60.0030.08720.10
7.0.50.0030.04717.93
7.0.40.0130.05720.22
7.0.30.0500.07720.25
7.0.20.0170.05320.07
7.0.10.0070.05720.23
7.0.00.0100.05320.15
5.6.280.0070.07021.06
5.6.210.0100.07720.58
5.6.200.0070.05718.20
5.6.190.0130.03720.63
5.6.180.3330.04720.41
5.6.170.0230.06020.47
5.6.160.0070.08320.54
5.6.150.0100.07718.29
5.6.140.0100.08018.18
5.6.130.0000.04718.15
5.6.120.0070.07021.05
5.6.110.0000.04321.13
5.6.100.0130.04321.00
5.6.90.0030.05021.09
5.6.80.0070.06020.41
5.6.70.4630.03320.49
5.5.350.0230.08020.44
5.5.340.0070.04017.98
5.5.330.0200.07720.18
5.5.320.0300.07320.51
5.5.310.0200.03720.41
5.5.300.0030.03718.08
5.5.290.0070.08717.97
5.5.280.0030.08720.91
5.5.270.0000.04320.75
5.5.260.0100.08320.66
5.5.250.0100.07720.56
5.5.240.0170.07020.28
5.4.450.0300.07019.46
5.4.440.0130.04719.60
5.4.430.0270.03319.45
5.4.420.0270.07019.33
5.4.410.0330.05019.06
5.4.400.0130.05018.74
5.4.390.0100.07318.80
5.4.380.0200.06018.54
5.4.370.0270.04018.74
5.4.360.0030.06318.59
5.4.350.0170.05318.55
5.4.340.0330.06018.77
5.4.320.0060.03712.51
5.4.310.0090.03312.51
5.4.300.0050.03812.51
5.4.290.0090.03812.51
5.4.280.0070.03512.41
5.4.270.0040.03812.41
5.4.260.0130.03412.41
5.4.250.0060.03912.41
5.4.240.0060.03612.41
5.4.230.0060.03912.40
5.4.220.0110.04912.40
5.4.210.0090.04612.40
5.4.200.0030.04012.40
5.4.190.0100.06318.90
5.4.180.0070.05319.22
5.4.170.0130.05019.08
5.4.160.0030.05719.00
5.4.150.0030.06018.98
5.4.140.0130.04716.41
5.4.130.0100.05016.38
5.4.120.0070.05316.70
5.4.110.0170.05316.65
5.4.100.0130.04716.48
5.4.90.0070.05316.57
5.4.80.0130.04316.67
5.4.70.0070.05016.59
5.4.60.0100.05016.62
5.4.50.0170.06716.66
5.4.40.0070.05016.66
5.4.30.0100.06016.59
5.4.20.0000.05716.45
5.4.10.0130.05316.65
5.4.00.0170.05316.07
5.3.290.0060.04012.80
5.3.280.0070.04212.71
5.3.270.0070.06014.63
5.3.260.0100.05314.81
5.3.250.0130.05314.69
5.3.240.0070.05014.81
5.3.230.0200.04014.88
5.3.220.0100.05014.47
5.3.210.0130.05314.87
5.3.200.0100.04714.64
5.3.190.0100.05014.66
5.3.180.0170.06714.85
5.3.170.0100.05014.48
5.3.160.0070.05314.76
5.3.150.0070.07314.77
5.3.140.0130.05014.58
5.3.130.0100.05314.45
5.3.120.0070.08014.75
5.3.110.0130.04714.85
5.3.100.0130.06014.24
5.3.90.0230.03714.34
5.3.80.0070.07314.11
5.3.70.0130.06314.24
5.3.60.0130.06014.32
5.3.50.0130.04714.17
5.3.40.0070.06014.03
5.3.30.0100.06313.93
5.3.20.0030.05713.60
5.3.10.0000.06013.69
5.3.00.0130.06313.84
5.2.170.0100.04311.34
5.2.160.0130.03711.05
5.2.150.0100.05011.29
5.2.140.0030.05011.43
5.2.130.0100.04011.00
5.2.120.0000.04711.30
5.2.110.0100.04011.35
5.2.100.0130.03011.12
5.2.90.0070.03711.31
5.2.80.0030.04311.18
5.2.70.0070.04011.30
5.2.60.0030.05311.32
5.2.50.0100.04011.16
5.2.40.0030.04711.31
5.2.30.0070.05311.29
5.2.20.0070.04011.27
5.2.10.0070.04011.15
5.2.00.0170.03310.97
5.1.60.0170.03010.33
5.1.50.0070.04010.31
5.1.40.0070.03310.12
5.1.30.0000.04010.54
5.1.20.0170.03710.38
5.1.10.0070.03710.25
5.1.00.0070.03310.39
5.0.50.0030.0308.46
5.0.40.0100.0308.43
5.0.30.0070.0438.56
5.0.20.0070.0278.41
5.0.10.0070.0308.29
5.0.00.0030.0438.40
4.4.90.0000.0337.41
4.4.80.0030.0207.41
4.4.70.0100.0137.41
4.4.60.0000.0237.41
4.4.50.0070.0207.41
4.4.40.0100.0307.41
4.4.30.0070.0277.41
4.4.20.0100.0237.41
4.4.10.0070.0177.41
4.4.00.0000.0407.41
4.3.110.0100.0207.41
4.3.100.0100.0207.41
4.3.90.0030.0207.41
4.3.80.0030.0407.41
4.3.70.0000.0237.41
4.3.60.0000.0237.41
4.3.50.0000.0237.41
4.3.40.0000.0407.41
4.3.30.0100.0177.41
4.3.20.0030.0277.41
4.3.10.0000.0337.41
4.3.00.0030.0275.85

preferences:
55.86 ms | 400 KiB | 5 Q