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 $iterationCount = 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->iterationCount; } 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->iterationCount++; 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.0180.00718.68
8.3.50.0160.00922.11
8.3.40.0110.00718.96
8.3.30.0130.00619.04
8.3.20.0190.00320.30
8.3.10.0000.01021.56
8.3.00.0030.00718.03
8.2.180.0150.00418.29
8.2.170.0060.01222.96
8.2.160.0100.01020.39
8.2.150.0050.00524.18
8.2.140.0030.00624.66
8.2.130.0150.00726.16
8.2.120.0060.00319.36
8.2.110.0040.00820.50
8.2.100.0070.00718.22
8.2.90.0040.00719.20
8.2.80.0060.00317.97
8.2.70.0040.00817.75
8.2.60.0060.00318.05
8.2.50.0070.00318.07
8.2.40.0000.01020.07
8.2.30.0000.00918.31
8.2.20.0000.00917.76
8.2.10.0030.00718.16
8.2.00.0000.00917.82
8.1.280.0140.00625.92
8.1.270.0040.00423.96
8.1.260.0030.00626.35
8.1.250.0050.00528.09
8.1.240.0060.00623.65
8.1.230.0090.00619.21
8.1.220.0050.00517.77
8.1.210.0030.00618.77
8.1.200.0000.01117.47
8.1.190.0060.00317.38
8.1.180.0000.00918.10
8.1.170.0050.00518.59
8.1.160.0030.00622.00
8.1.150.0000.00918.91
8.1.140.0090.00317.40
8.1.130.0000.00817.91
8.1.120.0060.00317.51
8.1.110.0000.01017.40
8.1.100.0060.00317.45
8.1.90.0000.00917.39
8.1.80.0030.00617.50
8.1.70.0030.00617.45
8.1.60.0030.00717.66
8.1.50.0100.00017.57
8.1.40.0000.01017.54
8.1.30.0000.01117.59
8.1.20.0030.00717.71
8.1.10.0000.00917.52
8.1.00.0030.00617.51
8.0.300.0090.00018.77
8.0.290.0030.00616.75
8.0.280.0060.00318.33
8.0.270.0000.01117.29
8.0.260.0060.00317.28
8.0.250.0000.01017.03
8.0.240.0030.00617.06
8.0.230.0060.00317.02
8.0.220.0000.00817.00
8.0.210.0000.00916.96
8.0.200.0000.00917.06
8.0.190.0000.01017.02
8.0.180.0060.00316.91
8.0.170.0000.01017.00
8.0.160.0000.00916.86
8.0.150.0070.00316.97
8.0.140.0030.01016.86
8.0.130.0000.00813.38
8.0.120.0030.00716.85
8.0.110.0030.00716.97
8.0.100.0030.00616.79
8.0.90.0000.00917.02
8.0.80.0070.01417.00
8.0.70.0030.00716.95
8.0.60.0030.00616.93
8.0.50.0060.00317.04
8.0.30.0190.01217.03
8.0.20.0150.01517.40
8.0.10.0000.00917.06
8.0.00.0150.01416.71
7.4.330.0030.00315.15
7.4.320.0000.00816.53
7.4.300.0000.00916.63
7.4.290.0030.00616.64
7.4.280.0060.00316.39
7.4.270.0030.00616.56
7.4.260.0030.00616.68
7.4.250.0000.00916.59
7.4.240.0040.00516.59
7.4.230.0040.00416.29
7.4.220.0100.02716.60
7.4.210.0110.00916.71
7.4.200.0090.00016.47
7.4.160.0090.02616.42
7.4.150.0160.01217.40
7.4.140.0120.01517.86
7.4.130.0150.01716.67
7.4.120.0190.01216.49
7.4.110.0190.01016.61
7.4.100.0250.01416.56
7.4.90.0230.00316.52
7.4.80.0130.01719.39
7.4.70.0100.02016.45
7.4.60.0170.00816.45
7.4.50.0060.00616.59
7.4.40.0150.01516.64
7.4.30.0090.01416.45
7.3.330.0030.00613.39
7.3.320.0070.00013.48
7.3.310.0060.00316.21
7.3.300.0080.00016.41
7.3.290.0200.01016.39
7.3.280.0170.01016.40
7.3.270.0120.01617.40
7.3.260.0160.00916.53
7.3.250.0260.00816.40
7.3.240.0180.01416.39
7.3.230.0220.01616.39
7.3.210.0110.01516.41
7.3.200.0190.01119.39
7.3.190.0100.01316.64
7.3.180.0150.00916.39
7.3.170.0170.02016.38
7.3.160.0150.00816.69
7.2.330.0110.01416.77
7.2.320.0130.01716.64
7.2.310.0080.01716.85
7.2.300.0090.01716.56
7.2.290.0100.02016.40
5.4.450.2570.04319.20
5.4.440.2770.04019.48
5.4.430.3270.03719.27
5.4.420.3070.04019.40
5.4.410.3070.03719.44
5.4.400.3270.04719.26
5.4.390.3000.04319.06
5.4.380.3200.04019.09
5.4.370.3000.04019.24
5.4.360.2970.04319.17
5.4.350.2700.04719.15
5.4.340.3000.04018.84
5.4.320.3230.03319.13
5.4.310.3470.04019.06
5.4.300.3200.04319.21
5.4.290.3200.04318.96
5.4.280.3430.04319.19
5.4.270.3400.05018.99
5.4.260.3370.04318.98
5.4.250.3530.03319.16
5.4.240.3530.03319.21
5.4.230.3430.03319.09
5.4.220.3430.04719.07
5.4.210.3470.04319.05
5.4.200.3730.03719.21
5.4.190.3570.04319.13
5.4.180.3770.05019.15
5.4.170.3400.04018.83
5.4.160.3200.04019.22
5.4.150.3170.04018.84
5.4.140.3500.04016.35
5.4.130.3830.03716.38
5.4.120.4030.04016.34
5.4.110.4000.03716.47
5.4.100.4230.03716.22
5.4.90.4100.03316.55
5.4.80.3970.04016.27
5.4.70.4130.03716.39
5.4.60.4070.04016.35
5.4.50.1930.03316.56
5.4.40.0030.08716.51
5.4.30.0100.04316.25
5.4.20.0070.05016.44
5.4.10.3270.04716.57
5.4.00.3430.04315.87
5.3.290.3530.02714.94
5.3.280.3430.04314.60
5.3.270.3430.04714.75
5.3.260.3430.04314.79
5.3.250.3270.03714.72
5.3.240.3330.04714.69
5.3.230.3270.04014.62
5.3.220.3500.05314.74
5.3.210.3570.03314.51
5.3.200.3630.04714.61
5.3.190.3500.03714.65
5.3.180.3230.04314.68
5.3.170.3630.04714.51
5.3.160.3470.04014.65
5.3.150.3530.05014.61
5.3.140.3400.04714.51
5.3.130.3370.04314.60
5.3.120.3400.04314.66
5.3.110.3530.03714.66
5.3.100.3300.04314.03
5.3.90.3370.04314.28
5.3.80.3470.03714.13
5.3.70.3530.03713.99

preferences:
30.84 ms | 401 KiB | 5 Q