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()) { $this->iteration++; for ($j = $i + 1; $j <= $this->lastIndex; $j++) { $this->iterators[$j]->rewind(); } break; } } } } $nestedIterator = new NestedIterator(); $nestedIterator->addIterator(new IncrementIterator(0, 5)); $nestedIterator->addIterator(new IncrementIterator(0, 5)); $nestedIterator->addIterator(new IncrementIterator(0, 5)); $nestedIterator->addIterator(new IncrementIterator(0, 5)); foreach ($nestedIterator as $key => $current) { list($a, $b, $c, $d) = $current; echo "[$key] => $a, $b, $c, $d\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.0130.01018.45
8.3.50.0130.01022.03
8.3.40.0200.00718.53
8.3.30.0040.01519.16
8.3.20.0030.00620.34
8.3.10.0030.00723.66
8.3.00.0070.00318.02
8.2.180.0160.00316.63
8.2.170.0140.00322.96
8.2.160.0170.00320.52
8.2.150.0060.00324.18
8.2.140.0070.00324.66
8.2.130.0080.00326.16
8.2.120.0100.00021.03
8.2.110.0060.00620.38
8.2.100.0100.00318.34
8.2.90.0030.00619.20
8.2.80.0030.00717.97
8.2.70.0080.00317.63
8.2.60.0000.00917.93
8.2.50.0030.00718.07
8.2.40.0100.00019.89
8.2.30.0050.00518.39
8.2.20.0050.00517.66
8.2.10.0040.00418.07
8.2.00.0030.00617.85
8.1.280.0130.01325.92
8.1.270.0080.00323.86
8.1.260.0060.00326.35
8.1.250.0060.00328.09
8.1.240.0000.01123.80
8.1.230.0030.01019.15
8.1.220.0050.00517.77
8.1.210.0060.00318.77
8.1.200.0030.00717.47
8.1.190.0050.00517.23
8.1.180.0030.00718.10
8.1.170.0050.00518.50
8.1.160.0060.00622.05
8.1.150.0030.00618.78
8.1.140.0060.00617.53
8.1.130.0000.00817.86
8.1.120.0030.00617.41
8.1.110.0060.00317.37
8.1.100.0050.00517.39
8.1.90.0000.01017.50
8.1.80.0030.00617.50
8.1.70.0060.00317.45
8.1.60.0060.00617.66
8.1.50.0090.00017.43
8.1.40.0030.00717.52
8.1.30.0040.00717.74
8.1.20.0030.00717.66
8.1.10.0050.00517.60
8.1.00.0030.00717.43
8.0.300.0040.00418.77
8.0.290.0000.00916.75
8.0.280.0060.00318.40
8.0.270.0060.00317.29
8.0.260.0000.00817.33
8.0.250.0030.00617.05
8.0.240.0030.00616.98
8.0.230.0030.00716.95
8.0.220.0030.00517.06
8.0.210.0030.00616.87
8.0.200.0000.01016.95
8.0.190.0090.00017.03
8.0.180.0030.00616.91
8.0.170.0000.01017.01
8.0.160.0040.00716.89
8.0.150.0110.00316.92
8.0.140.0060.00916.95
8.0.130.0000.01013.48
8.0.120.0000.01116.99
8.0.110.0000.00916.91
8.0.100.0060.00317.10
8.0.90.0000.01117.11
8.0.80.0120.00916.98
8.0.70.0060.00316.98
8.0.60.0070.00316.78
8.0.50.0030.00617.05
8.0.30.0110.01916.94
8.0.20.0240.01117.40
8.0.10.0040.00417.14
8.0.00.0140.01116.81
7.4.330.0070.00015.00
7.4.320.0000.00816.58
7.4.300.0000.00916.50
7.4.290.0030.00616.53
7.4.280.0030.00616.64
7.4.270.0000.00916.48
7.4.260.0070.00316.58
7.4.250.0030.00616.63
7.4.240.0060.00416.50
7.4.230.0090.00016.60
7.4.220.0100.02716.51
7.4.210.0030.01616.58
7.4.200.0040.00416.45
7.4.160.0100.01716.57
7.4.150.0110.01517.40
7.4.140.0160.00917.86
7.4.130.0100.02216.46
7.4.120.0090.01816.51
7.4.110.0100.01416.40
7.4.100.0120.01216.43
7.4.90.0170.00916.55
7.4.80.0110.01619.39
7.4.70.0190.01416.62
7.4.60.0230.00616.47
7.4.50.0000.00616.38
7.4.40.0200.00716.41
7.4.30.0090.01616.70
7.3.330.0030.00613.18
7.3.320.0040.00413.16
7.3.310.0000.00916.46
7.3.300.0030.00616.40
7.3.290.0120.00916.33
7.3.280.0140.01216.36
7.3.270.0100.01717.40
7.3.260.0140.01816.51
7.3.250.0160.02016.42
7.3.240.0110.01516.58
7.3.230.0070.01716.57
7.3.210.0150.00916.40
7.3.200.0150.00919.39
7.3.190.0090.01516.78
7.3.180.0120.00916.55
7.3.170.0110.01716.67
7.3.160.0140.00916.61
7.2.330.0090.01716.62
7.2.320.0100.01616.50
7.2.310.0090.01516.79
7.2.300.0130.02816.49
7.2.290.0070.01716.91
7.2.100.1840.00614.62
7.2.90.0180.00614.58
7.2.80.0200.01014.70
7.2.70.0700.01214.91
7.2.60.2260.00614.65
7.2.50.1020.00715.05
7.2.40.0040.02314.62
7.2.30.2600.01314.81
7.2.20.0740.01014.98
7.2.10.0560.01715.25
7.2.00.0080.02015.14
7.1.220.1060.01313.59
7.1.210.1730.01313.73
7.1.200.0410.00613.60
7.1.190.0360.01413.88
7.1.180.0110.01113.77
7.1.170.2090.01013.48
7.1.160.0080.01513.44
7.1.150.0160.00813.94
7.1.140.0180.00913.88
7.1.130.0210.00913.90
7.1.120.2790.01713.92
7.1.110.0180.00013.99
7.1.100.2420.00713.73
7.1.90.2950.01013.97
7.1.80.0180.00313.79
7.1.70.2840.01013.82
7.1.60.2370.01331.92
7.1.50.0500.02231.83
7.1.40.1820.01331.89
7.1.30.1830.01332.06
7.1.20.1610.01331.79
7.1.10.1610.00714.19
7.1.00.1450.01014.06
7.0.310.1800.01213.67
7.0.300.2180.00913.45
7.0.290.0900.00613.46
7.0.280.2550.00313.41
7.0.270.0160.01313.39
7.0.260.1690.01013.40
7.0.250.0610.00713.83
7.0.240.3050.00713.31
7.0.230.2370.00713.68
7.0.220.2160.01013.39
7.0.210.2720.01013.18
7.0.200.1650.02313.38
7.0.190.1560.01313.44
7.0.180.1620.00913.21
7.0.170.1810.01313.21
7.0.160.1600.01013.33
7.0.150.1650.01013.34
7.0.140.1520.01413.25
7.0.130.2470.01013.30
7.0.120.0140.01413.14
7.0.110.1920.00713.34
7.0.100.1560.00713.39
7.0.90.1590.01013.61
7.0.80.1450.01613.20
7.0.70.2010.00013.37
7.0.60.1870.00613.41
7.0.50.1390.00613.61
7.0.40.0260.01313.59
7.0.30.0160.00813.66
7.0.20.1310.01613.48
7.0.10.1400.01213.40
7.0.00.0330.00613.52
5.6.380.0090.01814.21
5.6.370.0120.01214.62
5.6.360.0160.01214.75
5.6.350.0120.01814.67
5.6.340.0110.01914.26
5.6.330.0070.02014.72
5.6.320.0130.01014.02
5.6.310.0180.01314.48
5.6.300.0090.01614.34
5.6.290.0160.01014.25
5.6.280.0110.01414.36
5.6.270.0130.01014.05
5.6.260.0040.01714.46
5.6.250.0120.01214.23
5.6.240.0040.01514.13
5.6.230.0100.01014.29
5.6.220.0090.01514.16
5.6.210.0080.01314.05
5.6.200.0040.02414.41
5.6.190.0160.00514.38
5.6.180.0160.01414.54
5.6.170.0200.00014.13
5.6.160.0120.01214.16
5.6.150.0060.02214.63
5.6.140.0090.01514.54
5.6.130.0040.02114.61
5.6.120.0160.01314.03
5.6.110.0110.00914.20
5.6.100.0090.01414.50
5.6.90.0030.02214.36
5.6.80.0080.01314.27
5.6.70.0110.01414.25
5.6.60.0160.00314.15
5.6.50.0100.01014.37
5.6.40.0160.01314.08
5.6.30.0040.02414.37
5.6.20.0130.01214.06
5.6.10.0150.01514.43
5.6.00.0110.01114.05
5.5.380.0100.01011.73
5.5.370.0080.01711.73
5.5.360.0120.01211.73
5.5.350.0080.01311.73
5.5.340.0140.01111.73
5.5.330.0080.01611.73
5.5.320.0030.02111.73
5.5.310.0110.00711.73
5.5.300.0070.01511.73
5.5.290.0040.01611.73
5.5.280.0080.01211.73
5.5.270.0030.02011.73
5.5.260.0090.01211.73
5.5.250.0090.01211.73
5.5.240.0150.00911.73
5.5.230.0040.01911.73
5.5.220.0060.01511.73
5.5.210.0070.01411.73
5.5.200.0080.00811.73
5.5.190.0000.01911.73
5.5.180.0150.00911.73
5.5.170.0180.01114.15
5.5.160.0070.01011.73
5.5.150.0060.01611.73
5.5.140.0160.00511.73
5.5.130.0130.01311.73
5.5.120.0160.01011.73
5.5.110.0150.00611.73
5.5.100.0060.01611.73
5.5.90.0100.01611.73
5.5.80.0140.00711.73
5.5.70.0070.01311.73
5.5.60.0090.01211.73
5.5.50.0140.01011.73
5.5.40.0110.00811.73
5.5.30.0130.01411.73
5.5.20.0160.00511.73
5.5.10.0220.00011.73
5.5.00.0080.01111.73
5.4.450.0090.00911.73
5.4.440.0030.01311.73
5.4.430.0150.00611.73
5.4.420.0070.01011.73
5.4.410.0080.00811.73
5.4.400.0040.01211.73
5.4.390.0070.01811.73
5.4.380.0140.00711.73
5.4.370.0140.00911.73
5.4.360.0130.01211.73
5.4.350.0100.01311.73
5.4.340.0040.01511.73
5.4.330.0030.01311.73
5.4.320.0030.01411.73
5.4.310.0080.01911.73
5.4.300.0130.00811.73
5.4.290.0090.00911.73
5.4.280.0120.00611.73
5.4.270.0160.00511.73
5.4.260.0180.00311.73
5.4.250.0130.00611.73
5.4.240.0130.00911.73
5.4.230.0100.01311.73
5.4.220.0140.00611.73
5.4.210.0140.01411.73
5.4.200.0140.00511.73
5.4.190.0060.01611.73
5.4.180.0180.00411.73
5.4.170.0160.00811.73
5.4.160.0050.01411.73
5.4.150.0140.00711.73
5.4.140.0140.00711.73
5.4.130.0130.01611.73
5.4.120.0170.00411.73
5.4.110.0170.01111.73
5.4.100.0110.01111.73
5.4.90.0060.02011.73
5.4.80.0090.01211.73
5.4.70.0170.00411.73
5.4.60.0150.00511.73
5.4.50.0110.00811.73
5.4.40.0150.01011.73
5.4.30.0060.01711.73
5.4.20.0100.01011.73
5.4.10.0090.01311.73
5.4.00.0070.01111.73
5.3.290.0100.00811.73
5.3.280.0030.01611.73
5.3.270.0030.01811.73
5.3.260.0060.01611.73
5.3.250.0030.02911.73
5.3.240.0110.01711.73
5.3.230.0080.01311.73
5.3.220.0070.01411.73
5.3.210.0110.01411.73
5.3.200.0110.01511.73
5.3.190.0040.01611.73
5.3.180.0130.01611.73
5.3.170.0000.02111.73
5.3.160.0000.02011.73
5.3.150.0150.01511.73
5.3.140.0100.01411.73
5.3.130.0170.01011.73
5.3.120.0090.01511.73
5.3.110.0060.01911.73
5.3.100.0130.01811.73
5.3.90.0100.02011.73
5.3.80.0120.01211.73
5.3.70.0070.01411.73
5.3.60.0120.01211.73
5.3.50.0090.01411.73
5.3.40.0160.01211.73
5.3.30.0050.01611.73
5.3.20.0110.01111.73
5.3.10.0090.01411.73
5.3.00.0070.01411.73

preferences:
45.02 ms | 401 KiB | 5 Q