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() { $this->iteration++; 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(); } } } } } $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 $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.0090.00918.56
8.3.50.0090.00622.09
8.3.40.0030.01318.88
8.3.30.0070.00719.04
8.3.20.0060.01220.31
8.3.10.0000.00821.83
8.3.00.0080.00017.79
8.2.180.0150.00416.75
8.2.170.0110.00422.96
8.2.160.0100.00720.34
8.2.150.0070.00724.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0150.00420.84
8.2.110.0050.00520.38
8.2.100.0080.00319.88
8.2.90.0090.00019.17
8.2.80.0000.00817.97
8.2.70.0000.00817.63
8.2.60.0040.00418.03
8.2.50.0030.00618.07
8.2.40.0000.00818.28
8.2.30.0000.00718.41
8.2.20.0040.00417.69
8.2.10.0000.00818.03
8.2.00.0030.00617.69
8.1.280.0070.01125.92
8.1.270.0000.00824.01
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0030.00623.91
8.1.230.0040.00819.10
8.1.220.0040.00417.91
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0000.00817.35
8.1.180.0040.00418.10
8.1.170.0000.00818.68
8.1.160.0030.00622.02
8.1.150.0040.00418.90
8.1.140.0050.00317.49
8.1.130.0030.00317.87
8.1.120.0040.00417.48
8.1.110.0080.00017.48
8.1.100.0040.00417.54
8.1.90.0000.00817.38
8.1.80.0040.00417.39
8.1.70.0000.00717.35
8.1.60.0030.00617.63
8.1.50.0040.00417.57
8.1.40.0000.00817.56
8.1.30.0040.00417.67
8.1.20.0040.00417.65
8.1.10.0000.00817.46
8.1.00.0030.00617.55
8.0.300.0000.00718.77
8.0.290.0090.00016.75
8.0.280.0040.00418.44
8.0.270.0000.00717.21
8.0.260.0080.00017.17
8.0.250.0000.00716.98
8.0.240.0000.00716.99
8.0.230.0040.00417.11
8.0.220.0040.00416.90
8.0.210.0000.00716.98
8.0.200.0070.00017.04
8.0.190.0000.00817.10
8.0.180.0030.00516.89
8.0.170.0030.00516.89
8.0.160.0040.00416.92
8.0.150.0060.00316.82
8.0.140.0040.00816.96
8.0.130.0060.00313.46
8.0.120.0030.00616.99
8.0.110.0040.00417.00
8.0.100.0040.00417.04
8.0.90.0050.00316.89
8.0.80.0030.01317.02
8.0.70.0000.00716.90
8.0.60.0040.00417.05
8.0.50.0030.00617.00
8.0.30.0150.00617.33
8.0.20.0130.00517.40
8.0.10.0000.00717.02
8.0.00.0110.00916.93
7.4.330.0030.00315.00
7.4.320.0030.00316.57
7.4.300.0060.00016.44
7.4.290.0000.00816.54
7.4.280.0040.00416.68
7.4.270.0040.00416.57
7.4.260.0000.00716.47
7.4.250.0020.00516.53
7.4.240.0000.00716.60
7.4.230.0000.00716.65
7.4.220.0150.01216.69
7.4.210.0090.00616.71
7.4.200.0000.00716.73
7.4.160.0110.00516.39
7.4.150.0040.01417.40
7.4.140.0110.00717.86
7.4.130.0120.01016.54
7.4.120.0100.01116.67
7.4.110.0130.00316.45
7.4.100.0130.00416.54
7.4.90.0100.00716.56
7.4.80.0140.01019.39
7.4.70.0080.01016.33
7.4.60.0090.00916.39
7.4.50.0000.00416.34
7.4.40.0120.00916.62
7.4.30.0060.01116.65
7.4.00.0090.00714.91
7.3.330.0060.00013.43
7.3.320.0030.00313.51
7.3.310.0070.00016.45
7.3.300.0000.00716.27
7.3.290.0160.00316.40
7.3.280.0080.01316.47
7.3.270.0110.00717.40
7.3.260.0120.00616.39
7.3.250.0070.01316.67
7.3.240.0040.01416.65
7.3.230.0140.00316.69
7.3.210.0120.00916.41
7.3.200.0110.00519.39
7.3.190.0160.00616.70
7.3.180.0030.01316.71
7.3.170.0100.00916.48
7.3.160.0100.00716.41
7.3.120.0110.00614.80
7.3.110.0140.00414.99
7.3.100.0070.01014.93
7.3.90.0040.01115.02
7.3.80.0050.00514.74
7.3.70.0090.00414.96
7.3.60.0040.00815.04
7.3.50.0070.00714.83
7.3.40.0030.01214.97
7.3.30.0100.00615.01
7.3.20.0030.01216.70
7.3.10.0120.00316.76
7.3.00.0030.00916.88
7.2.330.0120.00616.86
7.2.320.0040.01716.74
7.2.310.0130.00316.82
7.2.300.0060.01516.83
7.2.290.0120.00916.80
7.2.250.0000.01314.95
7.2.240.0070.01015.24
7.2.230.0140.00015.17
7.2.220.0060.00615.18
7.2.210.0030.01014.93
7.2.200.0090.00915.24
7.2.190.0040.01115.05
7.2.180.0030.00915.17
7.2.170.0030.00915.14
7.2.00.0060.00619.34
7.1.330.0030.01416.08
7.1.320.0070.01115.68
7.1.310.0040.00715.82
7.1.300.0040.00415.85
7.1.290.0090.00615.61
7.1.280.0090.00615.96
7.1.270.0040.01116.03
7.1.260.0060.01015.85
7.1.100.0070.01118.08
7.1.70.0040.01117.17
7.1.60.0070.00417.31
7.1.50.0030.01017.05
7.1.00.0000.08022.54
7.0.200.0060.01116.86
7.0.140.0100.06322.10
7.0.60.0070.07320.11
7.0.50.0030.04017.91
7.0.40.0030.04320.21
7.0.30.0330.06320.17
7.0.20.0270.08320.14
7.0.10.0070.08320.21
7.0.00.0200.04720.19
5.6.280.0070.07021.02
5.6.210.0170.07720.72
5.6.200.0070.07318.16
5.6.190.0100.05320.69
5.6.180.0130.05020.41
5.6.170.0400.07020.45
5.6.160.0170.07320.52
5.6.150.0030.08718.19
5.6.140.0100.03318.16
5.6.130.0070.08718.18
5.6.120.0030.04021.13
5.6.110.0100.04721.03
5.6.100.0030.07721.06
5.6.90.0100.08721.02
5.6.80.0000.04320.55
5.5.350.0270.06320.49
5.5.340.0030.06017.96
5.5.330.0130.07020.25
5.5.320.0000.05020.30
5.5.310.0200.04020.27
5.5.300.0100.07018.09
5.5.290.0100.03317.95
5.5.280.0070.07720.92
5.5.270.0070.03720.81
5.5.260.0170.07720.98
5.5.250.0100.04020.62
5.5.240.0100.07320.38
5.4.450.0600.06019.34
5.4.440.0300.05319.63
5.4.430.0270.05019.33
5.4.420.0130.05719.55
5.4.410.0230.05019.57
5.4.400.0300.04719.29
5.4.390.0100.06019.37
5.4.380.0970.05718.76
5.4.370.0800.05318.67
5.4.360.0970.04718.77
5.4.350.0770.06318.56
5.4.340.0830.06318.74
5.4.320.0040.04212.52
5.4.310.0080.03912.52
5.4.300.0080.04712.53
5.4.290.0080.03812.52
5.4.280.0080.03412.43
5.4.270.0080.03512.42
5.4.260.0070.03812.43
5.4.250.0070.03812.42
5.4.240.0050.03812.42
5.4.230.0050.03912.41
5.4.220.0100.03912.42
5.4.210.0080.03512.41
5.4.200.0080.03612.41
5.4.190.0090.03512.41
5.4.180.0080.03412.41
5.4.170.0110.03212.42
5.4.160.0060.03912.42
5.4.150.0040.04212.41
5.4.140.0050.03812.10
5.4.130.0090.03712.08
5.4.120.0050.03912.05
5.4.110.0080.03712.04
5.4.100.0070.03712.04
5.4.90.0040.04012.04
5.4.80.0070.03712.04
5.4.70.0040.03712.04
5.4.60.0040.03812.04
5.4.50.0070.03612.04
5.4.40.0060.03512.02
5.4.30.0040.04012.02
5.4.20.0080.03312.02
5.4.10.0030.03712.02
5.4.00.0070.03511.51
5.3.290.0100.03612.80
5.3.280.0060.03812.71
5.3.270.0100.04012.72
5.3.260.0080.05112.72
5.3.250.0040.04712.72
5.3.240.0040.04012.72
5.3.230.0070.03612.71
5.3.220.0050.03912.68
5.3.210.0100.04812.68
5.3.200.0110.03912.68
5.3.190.0070.03712.68
5.3.180.0070.04212.68
5.3.170.0030.04012.68
5.3.160.0040.04112.68
5.3.150.0070.05012.68
5.3.140.0050.04112.67
5.3.130.0070.04312.66
5.3.120.0110.04112.66
5.3.110.0080.05612.66
5.3.100.0090.04312.15
5.3.90.0050.04012.13
5.3.80.0040.04012.13
5.3.70.0030.04012.12
5.3.60.0060.03812.11
5.3.50.0100.03812.05
5.3.40.0060.04012.05
5.3.30.0120.04312.02
5.3.20.0040.04611.80
5.3.10.0100.04411.76
5.3.00.0060.03611.75
5.2.170.0020.0349.25
5.2.160.0090.0279.25
5.2.150.0060.0329.25
5.2.140.0060.0339.25
5.2.130.0050.0429.21
5.2.120.0090.0389.21
5.2.110.0100.0369.22
5.2.100.0040.0319.21
5.2.90.0060.0429.21
5.2.80.0080.0309.21
5.2.70.0030.0429.21
5.2.60.0060.0429.16
5.2.50.0060.0309.13
5.2.40.0050.0299.11
5.2.30.0040.0309.09
5.2.20.0040.0349.07
5.2.10.0060.0338.98
5.2.00.0050.0348.84
5.1.60.0060.0238.13
5.1.50.0080.0218.13
5.1.40.0040.0258.11
5.1.30.0030.0278.45
5.1.20.0070.0368.48
5.1.10.0050.0318.20
5.1.00.0050.0378.20
5.0.50.0080.0256.68
5.0.40.0040.0196.54
5.0.30.0040.0426.36
5.0.20.0080.0236.32
5.0.10.0070.0266.30
5.0.00.0020.0336.30
4.4.90.0020.0164.78
4.4.80.0010.0174.76
4.4.70.0030.0154.75
4.4.60.0030.0154.76
4.4.50.0010.0174.77
4.4.40.0050.0224.71
4.4.30.0030.0154.76
4.4.20.0050.0134.85
4.4.10.0020.0174.85
4.4.00.0030.0284.76
4.3.110.0000.0224.67
4.3.100.0020.0164.66
4.3.90.0010.0194.63
4.3.80.0030.0244.59
4.3.70.0010.0224.63
4.3.60.0030.0144.63
4.3.50.0030.0164.63
4.3.40.0020.0254.54
4.3.30.0030.0163.30
4.3.20.0040.0173.28
4.3.10.0030.0203.24
4.3.00.0030.01715.25

preferences:
42.28 ms | 401 KiB | 5 Q