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) { list($a, $b, $c, $d) = $current; echo "$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.0100.01018.42
8.3.50.0080.01221.99
8.3.40.0140.00718.96
8.3.30.0140.00719.22
8.3.20.0080.00020.20
8.3.10.0080.00021.82
8.3.00.0080.00017.89
8.2.180.0110.01116.63
8.2.170.0110.00422.96
8.2.160.0100.00320.10
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0080.00020.92
8.2.110.0060.00319.39
8.2.100.0040.00819.89
8.2.90.0000.00819.21
8.2.80.0080.00017.97
8.2.70.0040.00417.75
8.2.60.0050.00317.93
8.2.50.0030.00518.10
8.2.40.0080.00022.21
8.2.30.0090.00018.34
8.2.20.0000.00817.85
8.2.10.0050.00318.13
8.2.00.0040.00417.82
8.1.280.0100.01025.92
8.1.270.0050.00323.89
8.1.260.0080.00026.35
8.1.250.0050.00228.09
8.1.240.0060.00321.30
8.1.230.0090.00317.70
8.1.220.0000.00817.74
8.1.210.0050.00318.77
8.1.200.0100.00017.35
8.1.190.0030.00917.35
8.1.180.0040.00418.10
8.1.170.0080.00018.46
8.1.160.0040.00421.95
8.1.150.0000.00718.97
8.1.140.0000.00817.45
8.1.130.0000.00717.88
8.1.120.0040.00417.55
8.1.110.0000.00817.50
8.1.100.0000.00717.45
8.1.90.0030.00617.36
8.1.80.0050.00317.48
8.1.70.0030.00317.41
8.1.60.0090.00017.63
8.1.50.0050.00317.43
8.1.40.0000.00817.52
8.1.30.0080.00017.50
8.1.20.0100.00017.67
8.1.10.0040.00417.59
8.1.00.0050.00317.50
8.0.300.0070.00018.77
8.0.290.0040.00416.88
8.0.280.0080.00018.35
8.0.270.0030.00317.27
8.0.260.0030.00317.34
8.0.250.0030.00317.06
8.0.240.0030.00317.06
8.0.230.0070.00016.93
8.0.220.0080.00016.87
8.0.210.0040.00216.91
8.0.200.0000.00616.92
8.0.190.0070.00017.02
8.0.180.0080.00017.00
8.0.170.0030.00616.98
8.0.160.0030.00516.98
8.0.150.0040.00416.91
8.0.140.0000.01016.99
8.0.130.0060.00013.39
8.0.120.0030.00517.00
8.0.110.0000.00717.03
8.0.100.0030.00516.95
8.0.90.0000.00817.02
8.0.80.0090.01317.01
8.0.70.0050.00216.86
8.0.60.0040.00416.77
8.0.50.0000.00716.82
8.0.30.0120.00817.03
8.0.20.0080.01117.40
8.0.10.0030.00517.03
8.0.00.0100.00816.77
7.4.330.0030.00315.03
7.4.320.0000.00616.59
7.4.300.0030.00316.52
7.4.290.0030.00316.60
7.4.280.0000.00816.61
7.4.270.0050.00216.55
7.4.260.0000.00716.65
7.4.250.0040.00416.39
7.4.240.0020.00516.51
7.4.230.0000.00716.56
7.4.220.0070.01016.52
7.4.210.0090.00916.69
7.4.200.0080.00016.52
7.4.160.0150.00816.50
7.4.150.0160.00717.40
7.4.140.0170.01117.86
7.4.130.0080.01316.41
7.4.120.0110.00916.54
7.4.110.0100.00916.40
7.4.100.0120.01316.69
7.4.90.0130.00616.66
7.4.80.0070.01719.39
7.4.70.0060.01216.55
7.4.60.0110.01416.49
7.4.50.0040.00016.55
7.4.40.0030.01416.39
7.4.30.0130.00316.59
7.4.00.0100.00614.96
7.3.330.0000.00713.47
7.3.320.0030.00313.41
7.3.310.0080.00016.39
7.3.300.0030.00316.26
7.3.290.0030.01216.42
7.3.280.0070.01116.35
7.3.270.0040.01317.40
7.3.260.0090.01216.73
7.3.250.0100.01416.54
7.3.240.0100.01316.41
7.3.230.0120.00916.66
7.3.210.0000.02016.62
7.3.200.0060.01119.39
7.3.190.0190.00316.32
7.3.180.0080.00816.40
7.3.170.0100.01016.62
7.3.160.0070.01416.36
7.3.120.0040.01114.88
7.2.330.0140.00416.71
7.2.320.0090.00916.52
7.2.310.0040.01216.54
7.2.300.0160.01016.68
7.2.290.0070.01016.89
7.2.60.0270.00316.98
7.2.00.0070.01119.51
7.1.200.0030.00615.58
7.1.100.0090.00918.12
7.1.70.0040.00417.34
7.1.60.0100.01419.25
7.1.50.0000.02116.97
7.1.00.0100.06322.33
7.0.200.0000.00716.54
7.0.140.0070.07022.12
7.0.60.0200.04319.91
7.0.50.0030.04717.90
7.0.40.0070.05020.09
7.0.30.0300.07020.09
7.0.20.0300.04020.07
7.0.10.0270.08320.21
7.0.00.0030.09020.25
5.6.280.0030.07021.15
5.6.210.0070.07320.65
5.6.200.0070.03718.14
5.6.190.0170.07720.63
5.6.180.0330.07720.59
5.6.170.0270.04720.55
5.6.160.0030.06720.71
5.6.150.0130.07318.14
5.6.140.0030.07718.19
5.6.130.0000.08018.21
5.6.120.0100.03721.06
5.6.110.0130.05321.11
5.6.100.0030.08720.99
5.6.90.0000.04321.00
5.6.80.0130.07320.43
5.6.70.4130.04020.39
5.5.350.0300.07720.40
5.5.340.0070.03718.05
5.5.330.0000.05320.37
5.5.320.0270.07020.19
5.5.310.0330.05020.26
5.5.300.0030.05717.97
5.5.290.0000.04317.94
5.5.280.0200.06720.91
5.5.270.0130.07720.89
5.5.260.0030.07320.91
5.5.250.0170.07020.72
5.5.240.0100.07320.29
5.4.450.0300.04019.31
5.4.440.0400.05019.54
5.4.430.0070.05719.54
5.4.420.0030.06319.52
5.4.410.0170.04719.04
5.4.400.0100.05318.63
5.4.390.0130.04718.84
5.4.380.0170.04718.79
5.4.370.0130.04718.78
5.4.360.0000.04318.78
5.4.350.0230.07712.04
5.4.340.0060.03812.04
5.4.320.0080.03512.53
5.4.310.0090.05012.52
5.4.300.0070.05312.52
5.4.290.0060.05112.53
5.4.280.0050.04812.42
5.4.270.0100.03512.43
5.4.260.0080.04612.42
5.4.250.0100.04112.42
5.4.240.0090.03712.42
5.4.230.0060.03912.41
5.4.220.0050.04212.42
5.4.210.0100.03112.42
5.4.200.0050.04012.41
5.4.190.0090.04212.41
5.4.180.0090.04812.41
5.4.170.0110.04212.42
5.4.160.0080.04312.42
5.4.150.0060.05012.41
5.4.140.0080.05112.10
5.4.130.0080.04812.09
5.4.120.0080.04912.04
5.4.110.0110.04712.04
5.4.100.0090.04212.04
5.4.90.0080.03612.04
5.4.80.0050.03812.04
5.4.70.0050.03612.04
5.4.60.0080.03312.04
5.4.50.0050.04112.04
5.4.40.0050.03612.02
5.4.30.0050.03912.02
5.4.20.0090.03612.02
5.4.10.0070.03412.02
5.4.00.0060.03511.51
5.3.290.0080.03712.80
5.3.280.0060.03912.71
5.3.270.0050.04212.72
5.3.260.0070.03912.72
5.3.250.0060.03912.72
5.3.240.0080.03712.72
5.3.230.0120.04712.71
5.3.220.0070.04412.68
5.3.210.0070.04812.68
5.3.200.0070.03612.68
5.3.190.0060.03912.68
5.3.180.0090.04212.68
5.3.170.0090.03612.68
5.3.160.0060.03812.68
5.3.150.0070.03712.68
5.3.140.0040.03912.66
5.3.130.0070.03812.67
5.3.120.0060.03912.66
5.3.110.0060.04112.66
5.3.100.0030.04112.15
5.3.90.0060.03712.13
5.3.80.0080.03612.12
5.3.70.0030.04012.13
5.3.60.0070.03612.11
5.3.50.0100.04312.05
5.3.40.0070.03812.05
5.3.30.0050.03812.02
5.3.20.0080.03811.79
5.3.10.0080.03411.76
5.3.00.0020.04011.75
5.2.170.0080.0319.26
5.2.160.0040.0339.25
5.2.150.0030.0339.26
5.2.140.0050.0319.25
5.2.130.0040.0309.21
5.2.120.0050.0319.21
5.2.110.0060.0299.22
5.2.100.0050.0299.21
5.2.90.0060.0289.21
5.2.80.0050.0319.21
5.2.70.0080.0289.21
5.2.60.0040.0319.16
5.2.50.0040.0319.13
5.2.40.0070.0279.11
5.2.30.0040.0329.08
5.2.20.0030.0319.07
5.2.10.0070.0268.97
5.2.00.0030.0328.84
5.1.60.0040.0258.13
5.1.50.0050.0268.13
5.1.40.0040.0258.10
5.1.30.0040.0278.45
5.1.20.0070.0288.47
5.1.10.0030.0288.20
5.1.00.0050.0268.20
5.0.50.0030.0226.68
5.0.40.0030.0216.54
5.0.30.0020.0346.36
5.0.20.0030.0216.32
5.0.10.0030.0256.30
5.0.00.0030.0326.29
4.4.90.0030.0164.78
4.4.80.0020.0174.76
4.4.70.0040.0144.76
4.4.60.0030.0164.75
4.4.50.0030.0154.77
4.4.40.0050.0264.71
4.4.30.0000.0194.76
4.4.20.0020.0174.84
4.4.10.0050.0134.85
4.4.00.0050.0234.76
4.3.110.0030.0154.67
4.3.100.0040.0204.66
4.3.90.0030.0204.64
4.3.80.0030.0244.58
4.3.70.0020.0154.63
4.3.60.0030.0144.63
4.3.50.0020.0204.63
4.3.40.0060.0214.54
4.3.30.0020.0163.30
4.3.20.0000.0183.28
4.3.10.0010.0173.24
4.3.00.0070.01715.25

preferences:
34.2 ms | 401 KiB | 5 Q