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()) { 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 $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.0030.01718.43
8.3.50.0170.00318.05
8.3.40.0030.01719.06
8.3.30.0100.00619.28
8.3.20.0050.00320.21
8.3.10.0050.00321.75
8.3.00.0110.00718.05
8.2.180.0190.00616.75
8.2.170.0110.00422.96
8.2.160.0070.00720.35
8.2.150.0120.00624.18
8.2.140.0050.00324.66
8.2.130.0000.00826.16
8.2.120.0000.00921.02
8.2.110.0100.00022.25
8.2.100.0090.00318.16
8.2.90.0000.00819.35
8.2.80.0090.00017.97
8.2.70.0030.00617.72
8.2.60.0030.00517.93
8.2.50.0030.00618.07
8.2.40.0040.00718.14
8.2.30.0020.00518.36
8.2.20.0040.00417.76
8.2.10.0070.00018.03
8.2.00.0000.00817.66
8.1.270.0050.00323.87
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0090.00022.16
8.1.230.0060.00619.14
8.1.220.0090.00017.74
8.1.210.0040.00418.77
8.1.200.0000.00817.11
8.1.190.0000.00917.38
8.1.180.0050.00318.10
8.1.170.0030.00618.50
8.1.160.0030.00522.04
8.1.150.0040.00418.86
8.1.140.0040.00417.39
8.1.130.0000.00717.81
8.1.120.0000.00717.46
8.1.110.0070.00017.52
8.1.100.0040.00417.38
8.1.90.0040.00417.55
8.1.80.0000.00817.47
8.1.70.0000.00717.44
8.1.60.0030.00617.65
8.1.50.0030.00517.56
8.1.40.0080.00017.59
8.1.30.0000.00917.55
8.1.20.0030.00617.52
8.1.10.0030.00517.61
8.1.00.0080.00017.41
8.0.300.0040.00418.77
8.0.290.0040.00416.75
8.0.280.0000.00718.43
8.0.270.0000.00717.35
8.0.260.0000.00717.21
8.0.250.0050.00316.95
8.0.240.0000.00616.92
8.0.230.0050.00216.99
8.0.220.0070.00016.92
8.0.210.0030.00516.96
8.0.200.0070.00016.94
8.0.190.0000.00717.06
8.0.180.0030.00516.92
8.0.170.0000.00816.96
8.0.160.0070.00017.09
8.0.150.0090.00316.95
8.0.140.0030.00716.93
8.0.130.0050.00313.45
8.0.120.0000.00816.97
8.0.110.0050.00216.98
8.0.100.0040.00416.93
8.0.90.0090.00016.79
8.0.80.0060.01017.02
8.0.70.0040.00417.05
8.0.60.0070.00016.88
8.0.50.0040.00416.83
8.0.30.0100.00917.16
8.0.20.0110.00817.40
8.0.10.0000.00717.04
8.0.00.0080.01217.06
7.4.330.0050.00015.04
7.4.320.0050.00316.65
7.4.300.0030.00316.54
7.4.290.0000.00716.48
7.4.280.0040.00416.45
7.4.270.0030.00316.64
7.4.260.0070.00016.55
7.4.250.0000.00716.66
7.4.240.0040.00416.57
7.4.230.0000.00716.60
7.4.220.0070.01916.62
7.4.210.0030.01016.59
7.4.200.0000.00716.53
7.4.160.0100.01416.58
7.4.150.0030.01517.40
7.4.140.0090.01217.86
7.4.130.0100.00916.53
7.4.120.0110.00716.57
7.4.110.0150.00416.54
7.4.100.0110.00816.57
7.4.90.0110.00716.44
7.4.80.0090.01219.39
7.4.70.0130.00516.55
7.4.60.0130.00416.43
7.4.50.0000.00516.17
7.4.40.0100.00716.48
7.4.30.0000.01616.55
7.4.00.0060.01014.89
7.3.330.0050.00013.28
7.3.320.0050.00013.34
7.3.310.0070.00016.40
7.3.300.0000.00716.42
7.3.290.0110.00816.37
7.3.280.0090.00916.40
7.3.270.0090.00917.40
7.3.260.0090.00916.75
7.3.250.0100.01216.60
7.3.240.0130.01016.47
7.3.230.0070.01016.39
7.3.210.0090.00916.44
7.3.200.0070.01719.39
7.3.190.0090.01316.57
7.3.180.0030.01316.46
7.3.170.0100.01316.68
7.3.160.0070.01416.47
7.3.120.0000.01415.00
7.2.330.0160.00316.50
7.2.320.0060.01316.69
7.2.310.0060.01016.71
7.2.300.0100.01316.66
7.2.290.0110.00516.61
7.2.00.0000.01119.22
7.1.100.0070.00718.23
7.1.70.0030.00617.27
7.1.60.0140.01119.25
7.1.50.0060.01517.06
7.1.00.0000.08022.32
7.0.200.0070.00316.71
7.0.140.0030.07322.14
7.0.60.0130.05020.13
7.0.50.0130.05017.91
7.0.40.0030.07020.27
7.0.30.0270.04020.09
7.0.20.0170.07320.16
7.0.10.0030.05720.06
7.0.00.0170.08020.22
5.6.280.0030.07321.16
5.6.210.0100.08020.53
5.6.200.0100.08018.20
5.6.190.0070.06020.39
5.6.180.0370.06320.50
5.6.170.0330.07020.55
5.6.160.0070.08020.54
5.6.150.0070.08018.16
5.6.140.0100.03718.23
5.6.130.0130.07718.19
5.6.120.0000.09321.02
5.6.110.0170.07320.91
5.6.100.0130.03721.09
5.6.90.0170.06721.10
5.6.80.0070.08320.55
5.5.350.0170.07020.46
5.5.340.0070.08017.99
5.5.330.0070.07020.44
5.5.320.0170.05720.32
5.5.310.0100.04720.34
5.5.300.0170.07317.98
5.5.290.0000.06017.98
5.5.280.0030.04020.91
5.5.270.0070.04720.79
5.5.260.0030.08020.91
5.5.250.0000.08020.53
5.5.240.0230.06720.30
5.4.450.0470.03319.57
5.4.440.0370.05319.47
5.4.430.0200.04019.54
5.4.420.0500.04719.52
5.4.410.0430.04019.41
5.4.400.0600.03019.17
5.4.390.0600.03719.20
5.4.380.0800.05718.67
5.4.370.0830.05018.73
5.4.360.0670.05318.76
5.4.350.0830.04318.74
5.4.340.0800.05318.76
5.4.320.0100.03712.53
5.4.310.0080.05112.53
5.4.300.0130.04912.53
5.4.290.0110.04912.52
5.4.280.0060.04012.43
5.4.270.0030.04312.42
5.4.260.0050.04912.42
5.4.250.0110.03712.42
5.4.240.0070.05412.42
5.4.230.0110.03612.42
5.4.220.0100.04012.41
5.4.210.0110.04812.41
5.4.200.0100.05012.41
5.4.190.0120.03612.41
5.4.180.0090.04912.41
5.4.170.0090.03512.42
5.4.160.0070.03612.42
5.4.150.0090.04412.41
5.4.140.0110.04812.09
5.4.130.0060.04312.09
5.4.120.0090.03412.05
5.4.110.0110.04912.04
5.4.100.0130.04012.04
5.4.90.0110.04812.04
5.4.80.0070.05712.04
5.4.70.0080.05812.03
5.4.60.0100.05012.04
5.4.50.0080.04212.04
5.4.40.0180.06412.03
5.4.30.0100.05112.02
5.4.20.0160.05612.02
5.4.10.0110.04512.02
5.4.00.0050.05311.50
5.3.290.0060.04112.80
5.3.280.0090.04312.71
5.3.270.0080.03812.72
5.3.260.0130.04112.72
5.3.250.0060.04512.72
5.3.240.0080.04312.72
5.3.230.0070.04812.71
5.3.220.0090.05412.68
5.3.210.0060.04112.68
5.3.200.0060.04012.68
5.3.190.0040.04212.68
5.3.180.0030.04012.68
5.3.170.0050.03712.68
5.3.160.0080.03612.68
5.3.150.0060.03912.68
5.3.140.0050.04012.67
5.3.130.0080.03812.66
5.3.120.0060.04112.66
5.3.110.0090.05112.66
5.3.100.0110.04712.15
5.3.90.0080.04312.13
5.3.80.0060.04212.13
5.3.70.0070.04012.13
5.3.60.0100.03712.11
5.3.50.0070.03812.06
5.3.40.0080.03812.05
5.3.30.0070.03712.02
5.3.20.0070.03511.79
5.3.10.0050.03711.76
5.3.00.0080.03611.75
5.2.170.0040.0339.25
5.2.160.0060.0299.25
5.2.150.0030.0339.26
5.2.140.0070.0299.25
5.2.130.0050.0299.21
5.2.120.0040.0309.21
5.2.110.0050.0319.22
5.2.100.0060.0349.21
5.2.90.0070.0359.21
5.2.80.0050.0449.21
5.2.70.0100.0329.21
5.2.60.0020.0359.16
5.2.50.0110.0339.13
5.2.40.0080.0289.11
5.2.30.0040.0369.08
5.2.20.0030.0339.07
5.2.10.0040.0308.98
5.2.00.0070.0288.84
5.1.60.0100.0238.13
5.1.50.0030.0278.12
5.1.40.0040.0278.10
5.1.30.0070.0268.45
5.1.20.0090.0258.48
5.1.10.0060.0348.20
5.1.00.0070.0278.20
5.0.50.0070.0226.68
5.0.40.0020.0236.54
5.0.30.0060.0316.36
5.0.20.0050.0286.32
5.0.10.0060.0216.30
5.0.00.0070.0376.30
4.4.90.0010.0194.78
4.4.80.0030.0204.76
4.4.70.0060.0184.75
4.4.60.0020.0204.76
4.4.50.0030.0154.77
4.4.40.0040.0244.71
4.4.30.0040.0144.76
4.4.20.0030.0164.84
4.4.10.0010.0184.85
4.4.00.0030.0314.75
4.3.110.0030.0174.67
4.3.100.0050.0204.66
4.3.90.0040.0164.63
4.3.80.0060.0224.58
4.3.70.0040.0144.63
4.3.60.0020.0164.63
4.3.50.0030.0154.63
4.3.40.0030.0264.54
4.3.30.0040.0153.30
4.3.20.0010.0173.28
4.3.10.0020.0213.23
4.3.00.0030.01715.25

preferences:
47.31 ms | 400 KiB | 5 Q