3v4l.org

run code in 300+ PHP versions simultaneously
<?php function chunk_iterator(Iterator $it, int $n) { $chunk = []; for($i = 0; $it->valid(); $i++){ $chunk[] = $it->current(); $it->next(); if(count($chunk) == $n){ yield $chunk; $chunk = []; } } if(count($chunk)){ yield $chunk; } } // For demonstration, create an iterator from array $arr = range(20, 40, 1); $it = new ArrayIterator($arr); // Iterate over the generator foreach(chunk_iterator($it, 6) as $c){ echo implode(',', $c)."\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.00618.43
8.3.50.0080.01218.32
8.3.40.0070.01118.83
8.3.30.0110.00418.48
8.3.20.0030.00521.76
8.3.10.0080.00021.90
8.3.00.0090.00021.60
8.2.180.0110.00425.92
8.2.170.0140.00719.13
8.2.160.0070.01020.24
8.2.150.0040.00425.66
8.2.140.0030.00624.66
8.2.130.0150.00326.16
8.2.120.0080.00019.88
8.2.110.0090.00019.21
8.2.100.0060.00617.91
8.2.90.0060.00317.75
8.2.80.0000.00818.73
8.2.70.0040.00417.63
8.2.60.0000.00817.75
8.2.50.0070.00618.79
8.2.40.0080.00618.45
8.2.30.0080.00618.41
8.2.20.0130.00118.39
8.2.10.0090.00418.83
8.2.00.0100.00318.41
8.1.280.0150.00625.92
8.1.270.0080.00023.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00419.13
8.1.230.0090.00321.04
8.1.220.0040.00417.78
8.1.210.0080.00018.77
8.1.200.0000.00817.35
8.1.190.0000.00817.36
8.1.180.0070.00518.81
8.1.170.0090.00418.52
8.1.160.0090.00518.67
8.1.150.0090.00518.67
8.1.140.0100.00419.31
8.1.130.0080.00618.76
8.1.120.0100.00318.17
8.1.110.0080.00618.19
8.1.100.0100.00418.16
8.1.90.0110.00318.21
8.1.80.0090.00518.22
8.1.70.0070.00718.17
8.1.60.0090.00618.25
8.1.50.0090.00518.19
8.1.40.0100.00618.24
8.1.30.0110.00618.23
8.1.20.0080.00718.25
8.1.10.0120.00218.23
8.1.00.0110.00418.22
8.0.300.0000.00719.98
8.0.290.0000.00716.75
8.0.280.0090.00418.50
8.0.270.0100.00418.01
8.0.260.0080.00619.06
8.0.250.0080.00518.04
8.0.240.0060.00818.07
8.0.230.0110.00318.01
8.0.220.0080.00618.01
8.0.210.0100.00318.00
8.0.200.0090.00518.03
8.0.190.0090.00418.05
8.0.180.0130.00118.05
8.0.170.0070.00718.05
8.0.160.0120.00318.00
8.0.150.0100.00418.00
8.0.140.0080.00518.02
8.0.130.0080.00516.84
8.0.120.0090.00518.03
8.0.110.0090.00418.03
8.0.100.0130.00117.97
8.0.90.0090.00517.97
8.0.80.0050.01218.01
8.0.70.0100.00518.02
8.0.60.0090.00418.07
8.0.50.0100.00318.04
8.0.30.0090.00818.07
8.0.20.0090.00918.10
8.0.10.0100.00518.09
8.0.00.0130.00717.60
7.4.330.0070.00417.94
7.4.320.0090.00417.33
7.4.300.0090.00417.88
7.4.290.0100.00317.90
7.4.280.0110.00317.85
7.4.270.0110.00317.89
7.4.260.0100.00317.92
7.4.250.0070.00617.86
7.4.240.0070.00617.91
7.4.230.0100.00217.85
7.4.220.0090.00417.95
7.4.210.0090.00717.38
7.4.200.0090.00417.91
7.4.190.0150.00318.57
7.4.180.0110.00518.57
7.4.160.0130.00318.57
7.4.150.0110.00518.57
7.4.140.0090.00718.57
7.4.130.0090.00817.88
7.4.120.0130.00317.88
7.4.110.0090.00617.88
7.4.100.0110.00517.86
7.4.90.0120.00417.87
7.4.80.0110.00718.84
7.4.70.0110.00617.92
7.4.60.0120.00517.92
7.4.50.0100.00517.84
7.4.40.0100.00717.88
7.4.30.0160.00018.57
7.4.20.0120.00318.57
7.4.10.0120.00418.57
7.4.00.0090.00716.75
7.3.330.0080.00316.78
7.3.320.0100.00316.83
7.3.310.0100.00217.85
7.3.300.0100.00217.83
7.3.290.0070.00617.82
7.3.280.0110.00817.10
7.3.270.0120.00318.57
7.3.260.0100.00816.93
7.3.250.0060.00818.57
7.3.240.0110.00617.20
7.3.230.0060.00917.81
7.3.220.0150.00118.57
7.3.210.0120.00417.95
7.3.200.0110.00417.83
7.3.190.0080.00817.92
7.3.180.0110.00517.94
7.3.170.0090.00717.86
7.3.160.0120.00717.96
7.3.150.0110.00518.57
7.3.140.0150.00118.57
7.3.130.0150.00218.57
7.3.120.0120.00417.33
7.3.110.0100.00817.31
7.3.100.0080.00817.27
7.3.90.0100.00517.39
7.3.80.0090.00617.29
7.3.70.0090.00517.38
7.3.60.0090.00717.28
7.3.50.0130.00217.32
7.3.40.0110.00816.37
7.3.30.0090.00616.74
7.3.20.0110.00317.60
7.3.10.0100.00717.48
7.3.00.0100.00617.65
7.2.340.0110.00518.57
7.2.330.0130.00417.98
7.2.320.0090.00817.96
7.2.310.0120.00518.00
7.2.300.0110.00517.86
7.2.290.0080.00917.91
7.2.280.0160.00018.57
7.2.270.0090.00718.57
7.2.260.0120.00418.57
7.2.250.0090.00717.37
7.2.240.0110.00617.35
7.2.230.0070.00917.34
7.2.220.0100.00617.43
7.2.210.0120.00417.36
7.2.200.0110.00517.28
7.2.190.0140.00317.34
7.2.180.0120.00317.30
7.2.170.0090.00616.83
7.2.160.0080.00817.27
7.2.150.0090.00718.04
7.2.140.0120.00317.98
7.2.130.0130.00818.00
7.2.120.0120.00618.03
7.2.110.0120.00718.02
7.2.100.0090.00918.01
7.2.90.0170.00518.09
7.2.80.0140.00418.09
7.2.70.0090.00618.03
7.2.60.0120.00418.04
7.2.50.0120.00617.98
7.2.40.0080.00918.04
7.2.30.0120.00518.01
7.2.20.0090.00718.01
7.2.10.0130.00318.01
7.2.00.0130.00618.02
7.1.330.0090.00517.53
7.1.320.0130.00217.61
7.1.310.0100.00417.63
7.1.300.0110.00417.66
7.1.290.0090.00617.61
7.1.280.0060.00717.19
7.1.270.0080.00717.08
7.1.260.0090.00417.02
7.1.250.0110.00517.71
7.1.240.0080.00618.57
7.1.230.0130.00318.57
7.1.220.0090.00718.57
7.1.210.0240.00618.57
7.1.200.0100.00518.57
7.1.190.0090.00518.57
7.1.180.0130.00218.57
7.1.170.0120.00218.57
7.1.160.0100.00518.57
7.1.150.0150.00018.57
7.1.140.0110.00318.57
7.1.130.0120.00318.57
7.1.120.0100.00618.57
7.1.110.0110.00418.57
7.1.100.0140.00018.57
7.1.90.0100.00518.57
7.1.80.0090.00518.57
7.1.70.0100.00718.57
7.1.60.0130.00218.57
7.1.50.0100.00518.57
7.1.40.0090.00518.57
7.1.30.0090.00618.57
7.1.20.0110.00418.57
7.1.10.0100.00518.57
7.1.00.0090.00518.57

preferences:
68.39 ms | 401 KiB | 5 Q