3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! function iterator_compose(\Traversable $source, $steps) { foreach ($steps as $step) { $gen = $source; if (is_array($step) and !is_callable($step)) { $g = array_shift($step); array_unshift($step, $gen); if (class_exists($g)) { $class = new \ReflectionClass($className); $gen = $class->newInstanceArgs($step); } else if (is_callable($g)) { $gen = call_user_func_array($g, $step); } } else if (is_callable($step)) { $gen = $step($gen); } } return $gen; } function iterator_chunk(\Traversable $it, $chunkSize) { $it->rewind(); $chunk = []; $steps = range(1, $chunkSize); while (true) { foreach ($steps as $_) { if (!$it->valid()) { break 2; } $chunk[] = $it->current(); $it->next(); } yield $chunk; $chunk = []; } if ($chunk) { yield $chunk; } } $steps = [ function($it) { foreach ($it as $val) { echo "Value: $val\n"; yield $val; } }, ["iterator_chunk", 32], ]; $it = iterator_compose(new \ArrayIterator(range(0, 127)), $steps); foreach ($it as $i => $c) { echo "====== Chunk $i ======\n"; var_export($c); echo "\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.0120.00616.63
8.3.50.0090.00921.09
8.3.40.0160.00618.79
8.3.30.0070.00719.07
8.3.20.0080.00020.38
8.3.10.0000.00821.95
8.3.00.0040.00422.39
8.2.180.0040.01116.75
8.2.170.0160.00322.96
8.2.160.0100.00320.39
8.2.150.0040.00424.18
8.2.140.0090.00624.66
8.2.130.0080.00826.16
8.2.120.0060.00321.06
8.2.110.0060.00320.51
8.2.100.0110.00019.38
8.2.90.0040.00419.20
8.2.80.0050.00618.03
8.2.70.0030.00617.75
8.2.60.0040.00417.80
8.2.50.0030.00618.07
8.2.40.0050.00318.02
8.2.30.0000.00818.21
8.2.20.0040.00417.72
8.2.10.0040.00417.82
8.2.00.0050.00317.86
8.1.280.0100.01025.92
8.1.270.0080.00020.30
8.1.260.0030.00626.35
8.1.250.0080.00028.09
8.1.240.0050.00523.80
8.1.230.0070.00419.13
8.1.220.0080.00017.74
8.1.210.0000.00818.77
8.1.200.0030.00617.38
8.1.190.0040.00417.53
8.1.180.0040.00418.75
8.1.170.0040.00418.50
8.1.160.0000.00722.21
8.1.150.0040.00418.58
8.1.140.0000.00817.54
8.1.130.0000.00717.76
8.1.120.0000.00817.47
8.1.110.0030.00517.46
8.1.100.0050.00217.50
8.1.90.0000.00717.50
8.1.80.0040.00417.41
8.1.70.0050.00317.49
8.1.60.0040.00417.63
8.1.50.0000.00717.60
8.1.40.0030.00617.48
8.1.30.0000.00817.59
8.1.20.0090.00017.59
8.1.10.0080.00017.48
8.1.00.0000.00917.50
8.0.300.0040.00418.77
8.0.290.0050.00317.18
8.0.280.0030.00318.48
8.0.270.0000.00817.17
8.0.260.0070.00016.92
8.0.250.0040.00417.05
8.0.240.0040.00416.96
8.0.230.0000.00717.05
8.0.220.0000.00816.98
8.0.210.0070.00016.95
8.0.200.0070.00016.93
8.0.190.0000.00717.05
8.0.180.0040.00416.99
8.0.170.0040.00416.99
8.0.160.0050.00316.86
8.0.150.0000.00716.90
8.0.140.0040.00416.93
8.0.130.0030.00313.39
8.0.120.0050.00316.97
8.0.110.0030.00517.00
8.0.100.0040.00417.00
8.0.90.0050.00216.78
8.0.80.0040.01116.93
8.0.70.0000.00716.79
8.0.60.0040.00416.96
8.0.50.0040.00417.04
8.0.30.0080.01217.13
8.0.20.0100.01017.40
8.0.10.0070.00016.99
8.0.00.0140.00316.97
7.4.330.0000.00515.00
7.4.320.0000.00616.49
7.4.300.0030.00316.52
7.4.290.0030.00316.67
7.4.280.0040.00416.47
7.4.270.0030.00316.40
7.4.260.0030.00316.41
7.4.250.0030.00416.59
7.4.240.0030.00316.58
7.4.230.0030.00316.70
7.4.220.0070.01016.47
7.4.210.0070.00716.66
7.4.200.0080.00016.53
7.4.190.0030.00316.67
7.4.160.0080.00816.69
7.4.150.0090.01217.40
7.4.140.0080.01117.86
7.4.130.0130.00716.54
7.4.120.0100.01016.48
7.4.110.0110.00616.54
7.4.100.0120.00616.63
7.4.90.0090.00916.64
7.4.80.0100.00719.39
7.4.70.0150.00916.48
7.4.60.0060.01016.52
7.4.50.0040.00416.40
7.4.40.0090.00622.77
7.4.30.0120.00616.56
7.4.00.0060.00915.25
7.3.330.0050.00013.48
7.3.320.0030.00313.41
7.3.310.0000.00816.32
7.3.300.0030.00316.46
7.3.290.0060.00916.43
7.3.280.0060.01016.47
7.3.270.0090.01317.40
7.3.260.0040.01516.47
7.3.250.0160.00216.40
7.3.240.0090.01416.41
7.3.230.0130.01316.39
7.3.210.0060.01616.41
7.3.200.0090.00919.39
7.3.190.0140.00316.71
7.3.180.0100.00616.39
7.3.170.0170.00016.42
7.3.160.0040.01816.47
7.3.120.0090.00614.93
7.2.330.0120.00616.68
7.2.320.0060.01216.89
7.2.310.0090.00916.56
7.2.300.0100.00716.79
7.2.290.0170.00016.66
7.2.00.0090.00619.46
7.1.100.0040.01117.82
7.1.70.0000.00716.97
7.1.60.0070.01719.82
7.1.50.0140.01017.03
7.1.00.0130.05022.51
7.0.200.0000.00816.79
7.0.140.0030.07321.98
7.0.100.0200.05719.95
7.0.90.0100.08319.92
7.0.80.0200.03719.88
7.0.70.0230.06019.89
7.0.60.0100.07319.96
7.0.50.0070.08020.40
7.0.40.0030.07720.14
7.0.30.0070.05720.10
7.0.20.0070.07720.17
7.0.10.0070.05320.04
7.0.00.0030.09320.09
5.6.280.0030.07321.04
5.6.250.0030.08720.57
5.6.240.0070.08320.64
5.6.230.0100.06320.61
5.6.220.0070.04320.54
5.6.210.0030.07720.59
5.6.200.0070.08320.99
5.6.190.0170.07021.05
5.6.180.0130.06320.98
5.6.170.0030.08321.05
5.6.160.0130.08021.06
5.6.150.0100.09021.04
5.6.140.0130.08021.17
5.6.130.0070.04721.07
5.6.120.0200.06721.14
5.6.110.0030.09021.08
5.6.100.0030.07021.09
5.6.90.0000.07721.14
5.6.80.0100.06720.46
5.6.70.0170.07320.39
5.6.60.0170.07320.51
5.6.50.0170.07020.38
5.6.40.0100.05720.56
5.6.30.0100.07720.43
5.6.20.0130.06020.47
5.6.10.0100.06720.55
5.6.00.0100.07720.50
5.5.380.0070.06320.41
5.5.370.0170.07020.45
5.5.360.0030.07720.43
5.5.350.0130.08320.46
5.5.340.0100.08020.78
5.5.330.0100.08020.91
5.5.320.0000.08020.97
5.5.310.0100.07720.84
5.5.300.0130.03720.80
5.5.290.0130.07020.80
5.5.280.0170.06320.93
5.5.270.0070.08320.96
5.5.260.0170.07320.91
5.5.250.0070.06720.66
5.5.240.0300.05320.07
5.5.230.0130.08020.32
5.5.220.0070.08720.06
5.5.210.0030.05320.22
5.5.200.0030.05720.32
5.5.190.0070.08020.28
5.5.180.0170.05720.17
5.5.160.0130.07720.19
5.5.150.0100.07320.16
5.5.140.0130.06020.13
5.5.130.0070.05320.29
5.5.120.0100.07320.25
5.5.110.0130.04720.29
5.5.100.0070.08020.11
5.5.90.0100.07720.20
5.5.80.0070.08020.20
5.5.70.0030.08320.00
5.5.60.0200.05020.18
5.5.50.0100.07320.19
5.5.40.0030.04320.19
5.5.30.0030.08020.13
5.5.20.0070.08020.12
5.5.10.0030.04720.06
5.5.00.0100.03320.11
5.4.450.0070.04719.56
5.4.440.0100.07719.17
5.4.430.0100.05319.41
5.4.420.0070.07719.27
5.4.410.0070.07319.32
5.4.400.0070.08018.95
5.4.390.0070.06319.05
5.4.380.0100.04318.85
5.4.370.0130.06719.08
5.4.360.0030.08019.18
5.4.350.0030.04318.95
5.4.340.0030.04019.12
5.4.320.0070.07719.16
5.4.310.0070.05019.04
5.4.300.0000.07019.12
5.4.290.0030.04319.10
5.4.280.0130.04019.12
5.4.270.0030.04318.89
5.4.260.0070.08019.04
5.4.250.0100.07019.09
5.4.240.0070.07019.12
5.4.230.0030.04318.84
5.4.220.0130.07318.87
5.4.210.0100.07319.04
5.4.200.0070.07019.16
5.4.190.0130.07019.19
5.4.180.0130.03719.15
5.4.170.0030.07319.20
5.4.160.0100.06719.02
5.4.150.0070.07319.16
5.4.140.0030.07316.43
5.4.130.0030.08016.47
5.4.120.0100.07016.17
5.4.110.0070.06716.48
5.4.100.0170.06316.49
5.4.90.0030.06316.45
5.4.80.0000.07716.56
5.4.70.0070.04016.43
5.4.60.0030.07016.34
5.4.50.0100.07016.40
5.4.40.0070.03316.37
5.4.30.0070.06716.52
5.4.20.0100.07016.36
5.4.10.0070.05016.43
5.4.00.0030.04315.72
5.3.290.0070.07714.73
5.3.280.0070.06314.53
5.3.270.0070.05714.59
5.3.260.0030.05014.62
5.3.250.0070.07314.66
5.3.240.0070.04314.54
5.3.230.0070.04714.54
5.3.220.0070.03314.60
5.3.210.0100.04314.56
5.3.200.0100.04714.58
5.3.190.0070.07314.71
5.3.180.0100.04014.63
5.3.170.0100.03714.49
5.3.160.0070.07714.63
5.3.150.0030.08314.50
5.3.140.0070.04314.63
5.3.130.0030.06014.66
5.3.120.0130.06014.66
5.3.110.0070.04314.58
5.3.100.0100.06314.19
5.3.90.0000.04714.04
5.3.80.0070.05714.09
5.3.70.0070.06313.91
5.3.60.0070.07714.06
5.3.50.0130.03314.02
5.3.40.0130.06714.01
5.3.30.0030.04013.96
5.3.20.0030.06013.82
5.3.10.0100.07313.67
5.3.00.0130.03013.72
5.2.170.0000.05311.01
5.2.160.0070.02311.27
5.2.150.0070.03011.20
5.2.140.0000.04711.01
5.2.130.0170.05311.21
5.2.120.0030.06311.09
5.2.110.0070.04011.16
5.2.100.0030.06711.09
5.2.90.0000.06311.00
5.2.80.0130.05711.15
5.2.70.0070.05711.08
5.2.60.0030.05011.07
5.2.50.0130.05011.03
5.2.40.0070.05310.86
5.2.30.0030.06010.89
5.2.20.0100.03711.03
5.2.10.0030.06310.93
5.2.00.0000.05710.63
5.1.60.0030.03710.44
5.1.50.0100.04710.44
5.1.40.0030.03010.44
5.1.30.0070.03310.44
5.1.20.0070.02710.44
5.1.10.0030.04710.44
5.1.00.0070.05310.44
5.0.50.0100.03710.44
5.0.40.0070.04310.44
5.0.30.0030.06710.44
5.0.20.0030.04310.44
5.0.10.0070.02010.44
5.0.00.0100.04010.44
4.4.90.0130.02310.44
4.4.80.0000.03310.44
4.4.70.0000.02010.44
4.4.60.0000.01710.44
4.4.50.0000.01710.44
4.4.40.0030.05310.44
4.4.30.0030.03310.44
4.4.20.0000.03710.44
4.4.10.0030.03010.44
4.4.00.0030.05310.44
4.3.110.0000.02010.44
4.3.100.0100.02710.44
4.3.90.0030.01710.44
4.3.80.0000.05310.44
4.3.70.0000.02310.44
4.3.60.0030.02310.44
4.3.50.0070.02710.44
4.3.40.0100.04010.44
4.3.30.0070.03010.44
4.3.20.0000.03710.44
4.3.10.0000.03710.44
4.3.00.0000.02010.44

preferences:
35.93 ms | 401 KiB | 5 Q