3v4l.org

run code in 300+ PHP versions simultaneously
<?php class IncrementIterator implements Iterator { protected $start; protected $end; protected $current; public function __construct($start, $end) { $this->start = $start; $this->end = $end; } public function rewind() { $this->current = $this->start; } public function valid() { return $this->current <= $this->end; } public function key() { return $this->current; } public function current() { return $this->current; } public function next() { $this->current++; } } class NestedIterator implements Iterator { protected $iterators = array(); protected $lastIndex = -1; protected $iteration = 0; public function addIterator(Iterator $it) { $this->iterators[] = $it; $this->lastIndex++; } public function rewind() { foreach ($this->iterators as $it) { $it->rewind(); } $this->iteration = 0; } public function valid() { return $this->lastIndex >= 0 && $this->iterators[0]->valid(); } public function key() { return $this->iteration; } public function current() { $return = array(); foreach ($this->iterators as $it) { $return[] = $it->current(); } return $return; } public function next() { for ($i = $this->lastIndex; $i >= 0; $i--) { $this->iterators[$i]->next(); if (!$this->iterators[$i]->valid()) { continue; } for ($j = $i + 1; $j <= $this->lastIndex; $j++) { $this->iterators[$j]->rewind(); } } } } $nestedIterator = new NestedIterator(); $nestedIterator->addIterator(new IncrementIterator(0, 26)); $nestedIterator->addIterator(new IncrementIterator(0, 26)); $nestedIterator->addIterator(new IncrementIterator(0, 26)); $nestedIterator->addIterator(new IncrementIterator(0, 26)); foreach ($nestedIterator as $current) { var_dump($current); }

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.0060.00918.39
8.3.50.0140.00822.11
8.3.40.0080.00818.96
8.3.30.0110.00719.09
8.3.20.0040.00420.25
8.3.10.0110.00721.55
8.3.00.0050.00518.04
8.2.180.0170.00717.00
8.2.170.0110.00422.96
8.2.160.0070.00720.43
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0190.00021.01
8.2.110.0070.00319.45
8.2.100.0110.00019.76
8.2.90.0060.00319.14
8.2.80.0060.00317.97
8.2.70.0000.00817.63
8.2.60.0050.00318.01
8.2.50.0060.00318.10
8.2.40.0040.00422.18
8.2.30.0040.00418.20
8.2.20.0080.00017.82
8.2.10.0040.00418.01
8.2.00.0040.00417.75
8.1.280.0160.00625.92
8.1.270.0090.00023.71
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0090.00021.43
8.1.230.0120.00017.70
8.1.220.0000.00817.78
8.1.210.0040.00418.77
8.1.200.0070.00317.48
8.1.190.0040.00717.35
8.1.180.0080.00018.10
8.1.170.0030.00618.59
8.1.160.0030.00522.02
8.1.150.0020.00518.84
8.1.140.0050.00417.33
8.1.130.0070.00017.68
8.1.120.0070.00017.38
8.1.110.0070.00017.51
8.1.100.0000.00717.46
8.1.90.0000.00717.50
8.1.80.0030.00517.46
8.1.70.0000.00717.45
8.1.60.0040.00417.57
8.1.50.0000.00817.57
8.1.40.0040.00417.41
8.1.30.0050.00317.67
8.1.20.0030.00617.59
8.1.10.0040.00417.51
8.1.00.0040.00417.35
8.0.300.0040.00418.77
8.0.290.0050.00216.63
8.0.280.0000.00718.46
8.0.270.0040.00417.27
8.0.260.0030.00317.33
8.0.250.0000.00817.02
8.0.240.0000.00716.91
8.0.230.0000.00717.07
8.0.220.0070.00016.87
8.0.210.0000.00716.92
8.0.200.0040.00416.91
8.0.190.0030.00616.91
8.0.180.0040.00416.91
8.0.170.0040.00416.86
8.0.160.0050.00216.95
8.0.150.0100.00016.77
8.0.140.0030.00616.89
8.0.130.0090.00013.39
8.0.120.0000.00816.89
8.0.110.0000.00816.93
8.0.100.0050.00516.95
8.0.90.0040.00416.83
8.0.80.0060.01816.94
8.0.70.0040.00416.93
8.0.60.0040.00416.89
8.0.50.0060.00316.76
8.0.30.0100.01617.23
8.0.20.0140.01017.40
8.0.10.0000.00816.91
8.0.00.0100.01016.78
7.4.330.0030.00315.09
7.4.320.0030.00316.41
7.4.300.0050.00216.57
7.4.290.0070.00016.47
7.4.280.0040.00416.58
7.4.270.0070.00016.62
7.4.260.0080.00216.58
7.4.250.0000.00716.57
7.4.240.0040.00416.61
7.4.230.0040.00416.69
7.4.220.0150.00616.54
7.4.210.0090.00616.52
7.4.200.0050.00216.41
7.4.160.0040.01516.43
7.4.150.0190.00317.40
7.4.140.0120.01217.86
7.4.130.0110.01316.40
7.4.120.0110.01316.53
7.4.110.0170.00316.53
7.4.100.0130.01216.49
7.4.90.0170.00416.43
7.4.80.0120.01519.39
7.4.70.0120.00816.45
7.4.60.0070.01016.59
7.4.50.0050.00016.41
7.4.40.0130.01016.56
7.4.30.0160.00316.43
7.4.00.0030.01415.15
7.3.330.0030.00313.41
7.3.320.0070.00013.38
7.3.310.0070.00016.38
7.3.300.0040.00416.34
7.3.290.0090.01216.41
7.3.280.0050.01216.33
7.3.270.0170.00417.40
7.3.260.0150.00816.46
7.3.250.0110.00816.35
7.3.240.0150.00916.45
7.3.230.0070.01116.39
7.3.210.0090.00916.50
7.3.200.0110.00819.39
7.3.190.0120.00916.24
7.3.180.0150.00316.55
7.3.170.0180.00816.55
7.3.160.0050.01316.44
7.3.120.0130.00314.73
7.2.330.0090.00916.82
7.2.320.0070.01416.55
7.2.310.0100.00916.67
7.2.300.0080.01916.86
7.2.290.0070.01816.51
7.2.00.0070.00719.59
7.1.100.0030.01018.16
7.1.70.0040.00416.91
7.1.60.0110.01419.25
7.1.50.0100.01316.66
7.1.00.0030.07722.46
7.0.200.0000.00916.45
7.0.140.0030.07721.95
7.0.60.0100.04020.07
7.0.50.0100.04317.84
7.0.40.0000.05020.05
7.0.30.0200.05020.17
7.0.20.0230.04320.12
7.0.10.0070.08720.16
7.0.00.0170.07720.22
5.6.280.0000.07720.99
5.6.210.0070.05020.73
5.6.200.0030.04318.14
5.6.190.0030.04720.48
5.6.180.0200.03720.63
5.6.170.0270.08020.56
5.6.160.0100.07320.47
5.6.150.0100.07718.17
5.6.140.0000.08318.18
5.6.130.0070.06718.28
5.6.120.0030.09021.01
5.6.110.0130.08321.13
5.6.100.0100.07721.02
5.6.90.0030.08721.00
5.6.80.0100.03720.48
5.5.350.0230.07720.45
5.5.340.0070.05018.05
5.5.330.0070.04020.18
5.5.320.0230.04020.52
5.5.310.0400.07720.34
5.5.300.0100.07717.98
5.5.290.0100.06318.07
5.5.280.0100.07720.87
5.5.270.0070.07720.99
5.5.260.0030.08320.78
5.5.250.0030.04020.64
5.5.240.0000.08020.29
5.4.450.0870.05319.63
5.4.440.0200.06319.48
5.4.430.0070.06319.46
5.4.420.0170.05319.52
5.4.410.0170.05319.40
5.4.400.0200.05019.33
5.4.390.0200.05018.96
5.4.380.0130.05318.75
5.4.370.0200.04018.55
5.4.360.0200.05018.69
5.4.350.0200.07312.04
5.4.340.0070.03412.03
5.4.320.0070.03712.52
5.4.310.0050.04212.52
5.4.300.0050.04312.52
5.4.290.0070.04212.52
5.4.280.0070.03912.42
5.4.270.0100.03612.41
5.4.260.0120.04112.41
5.4.250.0030.04512.41
5.4.240.0100.04312.41
5.4.230.0060.05612.41
5.4.220.0120.04712.41
5.4.210.0110.04912.41
5.4.200.0080.04712.41
5.4.190.0060.03812.40
5.4.180.0070.04512.40
5.4.170.0070.03912.42
5.4.160.0080.03612.41
5.4.150.0090.03412.41
5.4.140.0090.03612.09
5.4.130.0080.03512.08
5.4.120.0070.04012.04
5.4.110.0090.03512.03
5.4.100.0120.03212.03
5.4.90.0060.03912.04
5.4.80.0130.05112.03
5.4.70.0110.04512.03
5.4.60.0090.04112.02
5.4.50.0080.03912.03
5.4.40.0100.03412.02
5.4.30.0040.04512.01
5.4.20.0060.03712.01
5.4.10.0070.04612.01
5.4.00.0050.04211.50
5.3.290.0080.03912.80
5.3.280.0110.04712.71
5.3.270.0070.04812.72
5.3.260.0090.04012.72
5.3.250.0070.04112.72
5.3.240.0080.03812.72
5.3.230.0070.03912.71
5.3.220.0080.03712.68
5.3.210.0130.03412.68
5.3.200.0070.03812.68
5.3.190.0060.03912.68
5.3.180.0110.03412.68
5.3.170.0160.04512.67
5.3.160.0050.04012.67
5.3.150.0070.03912.67
5.3.140.0040.04112.66
5.3.130.0090.03812.66
5.3.120.0060.04112.66
5.3.110.0120.03412.66
5.3.100.0080.04012.14
5.3.90.0060.03812.13
5.3.80.0050.03912.12
5.3.70.0050.03812.11
5.3.60.0040.03912.10
5.3.50.0090.03512.04
5.3.40.0040.03912.05
5.3.30.0070.04112.01
5.3.20.0090.03511.78
5.3.10.0080.03611.75
5.3.00.0030.04111.74
5.2.170.0050.0329.25
5.2.160.0080.0279.25
5.2.150.0060.0319.25
5.2.140.0050.0329.24
5.2.130.0060.0309.20
5.2.120.0060.0299.20
5.2.110.0040.0329.21
5.2.100.0080.0279.20
5.2.90.0050.0369.20
5.2.80.0060.0319.20
5.2.70.0060.0349.20
5.2.60.0070.0299.15
5.2.50.0050.0329.13
5.2.40.0060.0319.10
5.2.30.0080.0349.07
5.2.20.0070.0319.06
5.2.10.0060.0308.97
5.2.00.0050.0308.83
5.1.60.0040.0278.12
5.1.50.0090.0228.11
5.1.40.0020.0298.10
5.1.30.0060.0338.45
5.1.20.0070.0308.47
5.1.10.0070.0268.19
5.1.00.0050.0278.19
5.0.50.0040.0226.68
5.0.40.0060.0186.54
5.0.30.0060.0306.36
5.0.20.0030.0216.32
5.0.10.0060.0286.29
5.0.00.0040.0416.29
4.4.90.0040.0214.78
4.4.80.0020.0204.75
4.4.70.0030.0154.75
4.4.60.0050.0144.75
4.4.50.0030.0154.77
4.4.40.0020.0264.71
4.4.30.0040.0164.76
4.4.20.0030.0154.84
4.4.10.0040.0144.85
4.4.00.0020.0264.76
4.3.110.0040.0154.67
4.3.100.0010.0174.66
4.3.90.0020.0154.63
4.3.80.0030.0244.58
4.3.70.0020.0154.63
4.3.60.0030.0154.63
4.3.50.0050.0154.63
4.3.40.0000.0274.54
4.3.30.0020.0153.30
4.3.20.0050.0133.28
4.3.10.0020.0193.23
4.3.00.0200.0237.11

preferences:
34.88 ms | 401 KiB | 5 Q