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; } } class MyCollection implements IteratorAggregate { private $items = array(); private $count = 0; // Required definition of interface IteratorAggregate public function getIterator() { return new MyIterator($this->items); } public function add($value) { $this->items[$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.0040.01516.63
8.3.60.0000.01518.56
8.3.50.0130.00922.06
8.3.40.0090.00618.70
8.3.30.0080.00819.05
8.3.20.0040.00420.16
8.3.10.0080.00022.14
8.3.00.0080.00022.44
8.2.180.0120.00416.75
8.2.170.0120.00322.96
8.2.160.0090.00620.67
8.2.150.0040.00424.18
8.2.140.0040.01524.66
8.2.130.0040.00726.16
8.2.120.0040.00419.36
8.2.110.0040.00422.20
8.2.100.0090.00317.78
8.2.90.0050.00319.22
8.2.80.0040.00418.05
8.2.70.0030.00617.63
8.2.60.0000.00817.93
8.2.50.0080.00018.07
8.2.40.0040.00418.22
8.2.30.0040.00418.14
8.2.20.0070.00017.69
8.2.10.0000.00817.82
8.2.00.0000.00717.87
8.1.280.0130.01025.92
8.1.270.0040.00423.96
8.1.260.0050.00326.35
8.1.250.0140.00328.09
8.1.240.0060.00323.64
8.1.230.0060.00619.07
8.1.220.0030.00517.74
8.1.210.0040.00418.77
8.1.200.0060.00317.50
8.1.190.0000.00817.43
8.1.180.0030.00518.10
8.1.170.0000.00918.51
8.1.160.0040.00422.02
8.1.150.0040.00418.56
8.1.140.0000.01117.34
8.1.130.0000.00717.85
8.1.120.0050.00217.52
8.1.110.0020.00517.40
8.1.100.0030.00517.46
8.1.90.0000.00817.33
8.1.80.0000.00817.46
8.1.70.0090.00017.48
8.1.60.0030.00617.57
8.1.50.0040.00417.44
8.1.40.0000.00817.38
8.1.30.0040.00417.66
8.1.20.0050.00317.59
8.1.10.0030.00517.59
8.1.00.0000.00717.55
8.0.300.0030.00318.77
8.0.290.0070.00017.05
8.0.280.0040.00418.57
8.0.270.0000.00717.26
8.0.260.0000.00716.88
8.0.250.0080.00016.89
8.0.240.0040.00417.00
8.0.230.0030.00316.95
8.0.220.0000.00716.89
8.0.210.0070.00016.92
8.0.200.0030.00316.80
8.0.190.0040.00416.86
8.0.180.0000.00816.82
8.0.170.0000.00816.84
8.0.160.0070.00016.90
8.0.150.0030.00416.79
8.0.140.0050.00216.79
8.0.130.0030.00313.33
8.0.120.0040.00416.91
8.0.110.0070.00016.88
8.0.100.0020.00516.96
8.0.90.0030.00516.72
8.0.80.0090.00616.86
8.0.70.0050.00316.97
8.0.60.0050.00316.94
8.0.50.0050.00216.90
8.0.30.0090.01016.85
8.0.20.0080.01017.41
8.0.10.0070.00017.03
8.0.00.0120.00516.71
7.4.330.0050.00015.00
7.4.320.0070.00016.62
7.4.300.0040.00416.52
7.4.290.0030.00716.66
7.4.280.0030.00316.61
7.4.270.0070.00016.48
7.4.260.0060.00316.36
7.4.250.0070.00016.61
7.4.240.0040.00416.43
7.4.230.0070.00016.61
7.4.220.0100.01316.54
7.4.210.0080.00816.61
7.4.200.0030.00516.36
7.4.190.0070.00016.72
7.4.160.0110.00516.57
7.4.150.0000.01717.40
7.4.140.0120.00517.86
7.4.130.0110.00716.56
7.4.120.0090.01116.45
7.4.110.0090.00916.44
7.4.100.0060.01216.75
7.4.90.0030.01716.43
7.4.80.0070.01119.39
7.4.70.0100.00616.64
7.4.60.0120.00416.48
7.4.50.0030.00516.39
7.4.40.0000.01022.77
7.4.30.0100.00716.47
7.4.00.0060.00914.84
7.3.330.0060.00013.33
7.3.320.0000.00613.26
7.3.310.0040.00416.45
7.3.300.0000.00616.30
7.3.290.0080.00816.28
7.3.280.0070.00916.31
7.3.270.0030.01417.40
7.3.260.0090.00916.54
7.3.250.0140.00716.39
7.3.240.0180.00016.55
7.3.230.0080.01516.50
7.3.210.0120.00616.45
7.3.200.0070.01319.39
7.3.190.0120.00916.62
7.3.180.0060.01716.40
7.3.170.0060.01616.28
7.3.160.0070.01416.56
7.3.120.0110.00614.93
7.3.110.0100.00314.34
7.3.100.0090.00314.99
7.3.90.0120.00314.75
7.3.80.0060.00614.94
7.3.70.0070.00314.85
7.3.60.0040.00714.68
7.3.50.0060.00614.84
7.3.40.0030.00614.73
7.3.30.0080.00314.94
7.3.20.0030.00716.86
7.3.10.0090.01016.72
7.3.00.0080.00916.49
7.2.330.0090.00916.80
7.2.320.0030.01316.46
7.2.310.0120.00616.89
7.2.300.0080.00816.51
7.2.290.0000.01816.55
7.2.250.0070.01314.93
7.2.240.0070.01315.20
7.2.230.0090.00614.99
7.2.220.0070.01015.30
7.2.210.0030.01315.27
7.2.200.0070.00715.23
7.2.190.0060.00915.12
7.2.180.0000.01415.10
7.2.170.0120.00314.99
7.2.130.0170.00416.75
7.2.120.0100.01017.12
7.2.110.0030.01016.89
7.2.100.0070.00717.09
7.2.90.0060.00916.80
7.2.80.0060.00616.73
7.2.70.0060.00916.95
7.2.60.0030.00916.92
7.2.50.0080.00616.91
7.2.40.0060.00317.00
7.2.30.0040.01117.00
7.2.20.0100.00616.73
7.2.10.0070.01117.05
7.2.00.0020.01118.08
7.1.330.0110.00315.96
7.1.320.0060.00915.96
7.1.310.0000.01315.57
7.1.300.0030.00615.87
7.1.290.0070.00715.69
7.1.280.0070.00416.01
7.1.270.0060.00915.89
7.1.260.0090.00615.78
7.1.250.0130.01115.87
7.1.200.0070.00015.90
7.1.100.0040.01118.08
7.1.70.0030.00617.02
7.1.60.0090.01619.82
7.1.50.0210.01834.83
7.1.00.0070.07322.30
7.0.200.0150.00716.86
7.0.140.0070.07022.07
7.0.60.0070.06719.98
7.0.50.0070.07318.00
7.0.40.0070.07320.04
7.0.30.0270.04320.02
7.0.20.0300.08320.12
7.0.10.0200.06720.20
7.0.00.0070.08020.12
5.6.280.0070.07021.14
5.6.210.0130.07720.54
5.6.200.0030.06718.22
5.6.190.0070.08720.63
5.6.180.3770.04320.39
5.6.170.0270.04020.49
5.6.160.0100.04320.54
5.6.150.0030.04718.27
5.6.140.0100.07718.27
5.6.130.0030.08318.18
5.6.120.0100.04321.00
5.6.110.0070.07721.02
5.6.100.0070.07020.96
5.6.90.0200.07321.01
5.6.80.0130.04020.52
5.6.70.0070.07320.54
5.5.350.0030.04020.45
5.5.340.0030.06317.96
5.5.330.0070.04720.13
5.5.320.0400.03720.27
5.5.310.0230.07720.30
5.5.300.0030.06718.09
5.5.290.0100.03317.94
5.5.280.0130.07720.89
5.5.270.0070.04720.77
5.5.260.0130.05720.78
5.5.250.0100.06020.71
5.5.240.0070.08320.18
5.4.450.0570.04319.50
5.4.440.0430.04319.43
5.4.430.0270.05019.19
5.4.420.0300.04319.30
5.4.410.0100.05319.03
5.4.400.0130.05318.80
5.4.390.0130.04718.60
5.4.380.0400.05318.71
5.4.370.0230.04718.83
5.4.360.0270.04318.77
5.4.350.0170.05018.55
5.4.340.0270.04718.60
5.4.320.0030.04012.52
5.4.310.0070.03812.51
5.4.300.0070.03512.51
5.4.290.0070.04012.52
5.4.280.0040.04012.41
5.4.270.0050.03912.41
5.4.260.0070.03712.41
5.4.250.0050.03812.41
5.4.240.0040.03712.41
5.4.230.0080.04112.41
5.4.220.0040.03712.41
5.4.210.0040.03912.40
5.4.200.0040.04312.41
5.4.190.0160.04812.39
5.4.180.0150.04412.39
5.4.170.0170.04212.41
5.4.160.0160.04712.40
5.4.150.0230.04312.39
5.4.140.0250.04612.08
5.4.130.0420.08312.06
5.4.120.0160.04312.02
5.4.110.0150.04612.02
5.4.100.0140.04612.02
5.4.90.0160.04312.02
5.4.80.0100.04912.02
5.4.70.0160.04712.01
5.4.60.0150.04212.02
5.4.50.0150.04412.02
5.4.40.0170.04812.01
5.4.30.0110.04812.00
5.4.20.0170.04112.00
5.4.10.0200.06712.00
5.4.00.0130.04511.48
5.3.290.0060.04012.80
5.3.280.0050.03912.71
5.3.270.0190.04212.72
5.3.260.0220.04112.72
5.3.250.0180.04312.72
5.3.240.0190.04112.72
5.3.230.0160.04512.71
5.3.220.0140.04712.68
5.3.210.0120.05012.68
5.3.200.0230.04112.68
5.3.190.0160.04712.68
5.3.180.0290.09712.67
5.3.170.0160.04712.67
5.3.160.0190.04112.67
5.3.150.0170.04212.68
5.3.140.0130.04712.66
5.3.130.0240.06712.66
5.3.120.0200.04212.66
5.3.110.0130.04912.66
5.3.100.0160.04612.13
5.3.90.0140.04412.12
5.3.80.0240.06712.11
5.3.70.0180.04212.11
5.3.60.0110.04812.09
5.3.50.0170.04212.04
5.3.40.0140.04612.05
5.3.30.0150.04212.01
5.3.20.0160.04211.79
5.3.10.0150.04111.75
5.3.00.0180.03911.73
5.2.170.0110.0369.24
5.2.160.0120.0359.23
5.2.150.0160.0319.24
5.2.140.0110.0369.23
5.2.130.0120.0349.20
5.2.120.0120.0359.19
5.2.110.0120.0359.20
5.2.100.0110.0359.20
5.2.90.0090.0369.20
5.2.80.0140.0339.19
5.2.70.0260.0519.20
5.2.60.0130.0349.14
5.2.50.0130.0349.11
5.2.40.0130.0349.09
5.2.30.0110.0379.07
5.2.20.0110.0369.07
5.2.10.0140.0318.96
5.2.00.0130.0328.82
5.1.60.0120.0278.11
5.1.50.0110.0298.10
5.1.40.0140.0258.09
5.1.30.0180.0548.44
5.1.20.0110.0318.46
5.1.10.0060.0368.18
5.1.00.0140.0268.18
5.0.50.0080.0256.67
5.0.40.0080.0236.52
5.0.30.0090.0356.33
5.0.20.0080.0236.31
5.0.10.0080.0236.28
5.0.00.0130.0316.27
4.4.90.0080.0174.78
4.4.80.0090.0154.76
4.4.70.0060.0194.76
4.4.60.0050.0204.76
4.4.50.0090.0154.77
4.4.40.0090.0264.71
4.4.30.0190.0374.76
4.4.20.0060.0194.85
4.4.10.0080.0174.85
4.4.00.0070.0314.76
4.3.110.0070.0184.67
4.3.100.0070.0184.66
4.3.90.0070.0194.63
4.3.80.0100.0254.58
4.3.70.0060.0194.63
4.3.60.0080.0184.63
4.3.50.0070.0204.63
4.3.40.0160.0564.54
4.3.30.0080.0183.29
4.3.20.0060.0183.29
4.3.10.0060.0173.24
4.3.00.0100.01313.28

preferences:
69.98 ms | 401 KiB | 5 Q