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 $current) { $return[] = $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.70.0070.01116.88
8.3.60.0130.00618.55
8.3.50.0170.00822.09
8.3.40.0100.00719.11
8.3.30.0270.00319.07
8.3.20.0100.00020.01
8.3.10.0080.00321.90
8.3.00.0100.00018.03
8.2.180.0160.01016.75
8.2.170.0110.01522.96
8.2.160.0070.01020.47
8.2.150.0110.01124.18
8.2.140.0070.00324.66
8.2.130.0000.00926.16
8.2.120.0100.00021.07
8.2.110.0000.01322.27
8.2.100.0110.00417.72
8.2.90.0000.00917.87
8.2.80.0030.00618.75
8.2.70.0070.00317.50
8.2.60.0060.00317.63
8.2.50.0060.00317.75
8.2.40.0030.00617.63
8.2.30.0050.00517.87
8.2.20.0000.00917.77
8.2.10.0000.00918.13
8.2.00.0000.00917.76
8.1.280.0140.00325.92
8.1.270.0030.00723.86
8.1.260.0050.00526.35
8.1.250.0000.00928.09
8.1.240.0110.00022.74
8.1.230.0110.00419.01
8.1.220.0040.00417.74
8.1.210.0070.00318.77
8.1.200.0070.00317.35
8.1.190.0090.00017.35
8.1.180.0030.00618.10
8.1.170.0090.00017.62
8.1.160.0000.00918.89
8.1.150.0030.00618.89
8.1.140.0040.00417.50
8.1.130.0040.00417.78
8.1.120.0000.00817.52
8.1.110.0000.00817.44
8.1.100.0060.00317.36
8.1.90.0060.00317.50
8.1.80.0050.00317.46
8.1.70.0050.00517.36
8.1.60.0080.00317.61
8.1.50.0040.00417.52
8.1.40.0090.00017.54
8.1.30.0060.00317.56
8.1.20.0000.00917.57
8.1.10.0040.00417.60
8.1.00.0040.00417.42
8.0.300.0030.00518.77
8.0.290.0000.00916.75
8.0.280.0040.00418.02
8.0.270.0080.00018.14
8.0.260.0040.00417.15
8.0.250.0060.00317.02
8.0.240.0000.00816.93
8.0.230.0030.00617.04
8.0.220.0000.00816.89
8.0.210.0030.00516.97
8.0.200.0090.00016.95
8.0.190.0060.00316.91
8.0.180.0040.00416.95
8.0.170.0030.00617.02
8.0.160.0050.00316.92
8.0.150.0060.00316.88
8.0.140.0070.00316.84
8.0.130.0050.00313.27
8.0.120.0030.00616.82
8.0.110.0030.00616.89
8.0.100.0030.00617.04
8.0.90.0080.00016.99
8.0.80.0120.01216.95
8.0.70.0030.00616.97
8.0.60.0060.00317.02
8.0.50.0040.00416.75
8.0.30.0190.01417.20
8.0.20.0160.01617.40
8.0.10.0080.00017.13
8.0.00.0070.01916.92
7.4.330.0030.00315.00
7.4.320.0050.00316.44
7.4.300.0020.00516.51
7.4.290.0090.00016.52
7.4.280.0030.00616.62
7.4.270.0000.00816.52
7.4.260.0060.00316.56
7.4.250.0060.00316.59
7.4.240.0040.00416.52
7.4.230.0080.00016.43
7.4.220.0100.01616.67
7.4.210.0060.01616.69
7.4.200.0000.00916.62
7.4.160.0140.01116.46
7.4.150.0210.00617.40
7.4.140.0160.01517.86
7.4.130.0210.01016.49
7.4.120.0160.01216.55
7.4.110.0070.01816.39
7.4.100.0160.01916.49
7.4.90.0190.00716.58
7.4.80.0150.00919.39
7.4.70.0200.00716.41
7.4.60.0130.01216.60
7.4.50.0100.00016.43
7.4.40.0140.00916.62
7.4.30.0130.01216.49
7.4.00.0030.01515.18
7.3.330.0000.00713.21
7.3.320.0070.00013.16
7.3.310.0060.00316.43
7.3.300.0000.00916.27
7.3.290.0100.01016.47
7.3.280.0040.02016.41
7.3.270.0180.00917.40
7.3.260.0200.01316.48
7.3.250.0200.01216.37
7.3.240.0170.01816.68
7.3.230.0270.00016.39
7.3.210.0130.01216.47
7.3.200.0130.01019.39
7.3.190.0120.00916.34
7.3.180.0110.01116.55
7.3.170.0200.00916.63
7.3.160.0210.00016.71
7.3.120.0030.01315.04
7.3.10.0070.01016.70
7.3.00.0050.01216.59
7.2.330.0210.00616.84
7.2.320.0110.01416.88
7.2.310.0140.00916.68
7.2.300.0130.02016.79
7.2.290.0170.00716.78
7.2.130.0050.01116.92
7.2.120.0050.01217.05
7.2.110.0070.00917.01
7.2.100.0100.00716.91
7.2.90.0070.00916.96
7.2.80.0090.00716.96
7.2.70.0100.00817.01
7.2.60.0080.00816.96
7.2.50.0100.01017.00
7.2.40.0080.00717.02
7.2.30.0080.00816.82
7.2.20.0070.01016.84
7.2.10.0090.00617.01
7.2.00.0120.00617.81
7.1.250.0060.00615.89
7.1.100.0060.00617.94
7.1.70.0070.00717.27
7.1.60.0120.01619.25
7.1.50.0100.01417.01
7.1.00.0030.07322.36
7.0.200.0080.00316.73
7.0.140.0000.08021.95
7.0.60.0030.04019.83
7.0.50.0170.07717.89
7.0.40.0130.08720.02
7.0.30.0200.05320.33
7.0.20.0200.03720.15
7.0.10.0100.08720.07
7.0.00.0170.07720.14
5.6.280.0030.07321.14
5.6.210.0100.06320.62
5.6.200.0170.03318.16
5.6.190.0070.05720.64
5.6.180.0200.04320.50
5.6.170.0300.07720.47
5.6.160.0200.06720.71
5.6.150.0070.08318.29
5.6.140.0000.07318.13
5.6.130.0070.04018.18
5.6.120.0070.08321.11
5.6.110.0070.09020.86
5.6.100.0100.03721.02
5.6.90.0030.06021.09
5.6.80.0100.08020.39
5.5.350.0230.08020.55
5.5.340.0070.05718.05
5.5.330.0070.03720.28
5.5.320.0230.06020.52
5.5.310.0330.05320.32
5.5.300.0200.06017.93
5.5.290.0200.06018.04
5.5.280.0070.08020.67
5.5.270.0100.03720.89
5.5.260.0100.06320.89
5.5.250.0070.08020.81
5.5.240.0070.05320.25
5.4.450.0700.06719.47
5.4.440.0800.06019.61
5.4.430.0670.05319.59
5.4.420.0670.05319.46
5.4.410.0630.06019.52
5.4.400.0730.06719.18
5.4.390.0830.06719.22
5.4.380.0170.05318.77
5.4.370.0170.04018.46
5.4.360.0170.04018.54
5.4.350.0080.05112.04
5.4.340.0190.05712.03
5.4.320.0080.03912.52
5.4.310.0110.03912.52
5.4.300.0080.04012.52
5.4.290.0080.04112.52
5.4.280.0100.03612.41
5.4.270.0060.04112.41
5.4.260.0050.04112.41
5.4.250.0070.04212.41
5.4.240.0050.04212.41
5.4.230.0060.04412.40
5.4.220.0110.03312.41
5.4.210.0070.04412.41
5.4.200.0090.04012.40
5.4.190.0080.04012.40
5.4.180.0110.03712.41
5.4.170.0110.03612.41
5.4.160.0080.03912.41
5.4.150.0050.04412.41
5.4.140.0120.03912.09
5.4.130.0070.04212.07
5.4.120.0090.04112.04
5.4.110.0120.03812.04
5.4.100.0090.03712.03
5.4.90.0120.04112.03
5.4.80.0100.03812.03
5.4.70.0090.04712.03
5.4.60.0110.03512.03
5.4.50.0090.03812.03
5.4.40.0090.04112.01
5.4.30.0120.04212.01
5.4.20.0090.03812.00
5.4.10.0050.03612.01
5.4.00.0100.03611.50
5.3.290.0050.04112.80
5.3.280.0060.04312.71
5.3.270.0070.04212.73
5.3.260.0070.03912.72
5.3.250.0060.04212.72
5.3.240.0140.04112.72
5.3.230.0130.04312.71
5.3.220.0170.04912.68
5.3.210.0110.04112.68
5.3.200.0100.04012.68
5.3.190.0070.03912.68
5.3.180.0100.05212.67
5.3.170.0110.04012.67
5.3.160.0090.03912.68
5.3.150.0140.04612.68
5.3.140.0120.03912.66
5.3.130.0090.04312.65
5.3.120.0110.03912.66
5.3.110.0140.03712.66
5.3.100.0100.03912.14
5.3.90.0170.03812.14
5.3.80.0160.04712.12
5.3.70.0110.04112.11
5.3.60.0100.03812.10
5.3.50.0100.03712.04
5.3.40.0070.04712.05
5.3.30.0120.04112.01
5.3.20.0080.04011.79
5.3.10.0080.03911.75
5.3.00.0110.04311.74
5.2.170.0060.0369.25
5.2.160.0110.0369.25
5.2.150.0060.0369.25
5.2.140.0110.0349.24
5.2.130.0090.0449.20
5.2.120.0060.0349.20
5.2.110.0080.0339.21
5.2.100.0080.0329.20
5.2.90.0120.0299.20
5.2.80.0080.0339.20
5.2.70.0090.0389.20
5.2.60.0050.0359.15
5.2.50.0080.0329.13
5.2.40.0090.0309.09
5.2.30.0080.0319.07
5.2.20.0090.0279.06
5.2.10.0090.0288.96
5.2.00.0110.0278.83
5.1.60.0120.0248.12
5.1.50.0100.0258.11
5.1.40.0100.0248.10
5.1.30.0070.0328.44
5.1.20.0110.0268.47
5.1.10.0070.0288.19
5.1.00.0080.0248.20
5.0.50.0050.0246.68
5.0.40.0090.0196.54
5.0.30.0070.0326.36
5.0.20.0040.0236.32
5.0.10.0060.0226.29
5.0.00.0070.0326.29
4.4.90.0020.0164.78
4.4.80.0040.0144.75
4.4.70.0020.0164.76
4.4.60.0050.0134.75
4.4.50.0040.0144.77
4.4.40.0040.0244.71
4.4.30.0030.0154.76
4.4.20.0020.0174.85
4.4.10.0040.0174.85
4.4.00.0040.0244.76
4.3.110.0020.0164.67
4.3.100.0020.0154.66
4.3.90.0050.0124.64
4.3.80.0030.0244.58
4.3.70.0030.0154.63
4.3.60.0030.0144.63
4.3.50.0010.0174.63
4.3.40.0030.0234.54
4.3.30.0030.0153.30
4.3.20.0010.0173.28
4.3.10.0010.0213.23
4.3.00.0130.0207.11

preferences:
60.26 ms | 401 KiB | 5 Q