3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! function iterator_pipeline(\Traversable $source, $steps) { $gen = $source; foreach ($steps as $step) { 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; } } function iterator_consume(\Traversable $it) { foreach ($it as $key => $value) {} } function iterator_pass(\Traversable $it) { foreach ($it as $key => $value) { yield $key => $value; } } $steps = [ function($it) { foreach ($it as $val) { yield $val * 2; } }, "iterator_pass", ["iterator_chunk", 32], function($it) { foreach ($it as $val) { print_r($val); yield $val; } } ]; $it = iterator_pipeline(new \ArrayIterator(range(0, 127)), $steps); iterator_consume($it);

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.0160.00318.55
8.3.50.0080.00821.90
8.3.40.0070.00718.79
8.3.30.0110.00319.18
8.3.20.0000.00720.24
8.3.10.0040.00421.95
8.3.00.0050.00222.58
8.2.180.0140.00716.63
8.2.170.0070.01122.96
8.2.160.0040.01120.75
8.2.150.0040.00424.18
8.2.140.0000.00924.66
8.2.130.0000.00726.16
8.2.120.0080.00019.36
8.2.110.0050.00522.08
8.2.100.0090.00317.91
8.2.90.0030.00518.34
8.2.80.0000.00817.97
8.2.70.0000.00818.05
8.2.60.0080.00017.93
8.2.50.0080.00018.10
8.2.40.0090.00020.60
8.2.30.0000.00818.05
8.2.20.0070.00017.84
8.2.10.0080.00017.75
8.2.00.0060.00317.91
8.1.280.0120.00925.92
8.1.270.0040.00422.22
8.1.260.0030.00626.35
8.1.250.0030.00628.09
8.1.240.0030.00621.07
8.1.230.0120.00021.01
8.1.220.0000.00817.78
8.1.210.0000.00819.08
8.1.200.0050.00317.60
8.1.190.0060.00317.35
8.1.180.0040.00418.10
8.1.170.0060.00318.59
8.1.160.0030.00621.99
8.1.150.0050.00218.76
8.1.140.0070.00017.47
8.1.130.0050.00317.93
8.1.120.0040.00417.55
8.1.110.0040.00417.56
8.1.100.0040.00417.54
8.1.90.0000.00717.38
8.1.80.0040.00417.50
8.1.70.0000.00717.54
8.1.60.0040.00417.52
8.1.50.0000.00917.57
8.1.40.0020.00517.58
8.1.30.0020.00517.71
8.1.20.0080.00017.62
8.1.10.0000.00817.57
8.1.00.0030.00617.46
8.0.300.0050.00320.18
8.0.290.0030.00616.88
8.0.280.0030.00318.55
8.0.270.0080.00017.31
8.0.260.0040.00417.00
8.0.250.0030.00317.05
8.0.240.0030.00317.05
8.0.230.0050.00316.95
8.0.220.0040.00417.03
8.0.210.0030.00317.06
8.0.200.0030.00317.03
8.0.190.0030.00517.09
8.0.180.0030.00617.02
8.0.170.0000.00817.01
8.0.160.0000.00716.96
8.0.150.0040.00417.00
8.0.140.0030.00517.03
8.0.130.0060.00013.51
8.0.120.0000.00816.82
8.0.110.0080.00017.06
8.0.100.0000.00716.96
8.0.90.0030.00516.92
8.0.80.0140.00316.99
8.0.70.0000.00817.01
8.0.60.0000.00816.89
8.0.50.0040.00417.08
8.0.30.0060.01317.08
8.0.20.0100.00817.40
8.0.10.0040.00417.04
8.0.00.0140.00616.86
7.4.330.0030.00315.05
7.4.320.0030.00316.59
7.4.300.0030.00316.54
7.4.290.0050.00316.64
7.4.280.0030.00616.72
7.4.270.0030.00316.57
7.4.260.0060.00316.57
7.4.250.0050.00316.43
7.4.240.0040.00416.53
7.4.230.0070.00016.67
7.4.220.0030.01416.63
7.4.210.0100.00516.66
7.4.200.0000.00716.38
7.4.190.0000.00816.52
7.4.160.0080.00816.61
7.4.150.0060.01017.40
7.4.140.0120.00817.86
7.4.130.0110.00616.47
7.4.120.0120.00716.55
7.4.110.0060.01216.56
7.4.100.0070.01016.41
7.4.90.0080.00916.52
7.4.80.0070.01419.39
7.4.70.0120.00916.67
7.4.60.0090.00916.57
7.4.50.0040.00416.59
7.4.40.0030.01122.77
7.4.30.0060.01016.62
7.4.00.0030.00915.08
7.3.330.0060.00013.46
7.3.320.0030.00313.32
7.3.310.0000.00716.46
7.3.300.0000.00716.33
7.3.290.0040.01016.46
7.3.280.0070.01016.51
7.3.270.0030.01717.40
7.3.260.0070.01116.36
7.3.250.0060.01116.48
7.3.240.0160.00616.64
7.3.230.0100.00716.52
7.3.210.0100.00616.48
7.3.200.0170.00319.39
7.3.190.0030.01316.48
7.3.180.0030.01316.63
7.3.170.0170.00716.46
7.3.160.0060.01016.55
7.3.120.0060.00614.89
7.3.10.0080.00816.71
7.3.00.0040.00816.57
7.2.330.0140.00316.86
7.2.320.0130.00616.85
7.2.310.0100.01016.94
7.2.300.0090.00916.90
7.2.290.0040.01316.84
7.2.130.0070.01416.58
7.2.120.0030.01016.68
7.2.110.0030.00717.02
7.2.100.0070.00516.82
7.2.90.0000.01916.73
7.2.80.0100.00316.69
7.2.70.0100.00316.77
7.2.60.0100.00517.15
7.2.50.0000.01416.96
7.2.40.0030.00617.01
7.2.30.0080.00616.96
7.2.20.0040.01117.02
7.2.10.0000.00917.03
7.2.00.0030.01016.78
7.1.250.0030.01215.73
7.1.200.0090.00315.75
7.1.70.0030.00517.30
7.1.60.0080.00819.82
7.1.50.0040.02116.88
7.1.00.0030.07322.37
7.0.200.0050.00316.80
7.0.140.0070.07022.00
7.0.100.0100.07320.07
7.0.90.0170.07319.91
7.0.80.0100.06719.96
7.0.70.0100.08320.05
7.0.60.0100.07720.02
7.0.50.0100.07720.39
7.0.40.0170.06320.19
7.0.30.0030.07720.07
7.0.20.0030.09020.09
7.0.10.0130.07320.04
7.0.00.0100.07720.09
5.6.280.0130.06720.93
5.6.250.0030.08020.63
5.6.240.0070.07320.73
5.6.230.0130.08020.62
5.6.220.0130.07020.62
5.6.210.0100.07320.49
5.6.200.0130.07021.01
5.6.190.0070.08320.99
5.6.180.0100.07721.09
5.6.170.0200.07321.15
5.6.160.0170.07021.09
5.6.150.0030.07021.06
5.6.140.0070.08021.04
5.6.130.0130.08021.05
5.6.120.0100.08321.07
5.6.110.0170.07721.14
5.6.100.0170.04720.96
5.6.90.0000.08021.08
5.6.80.0030.08020.47
5.6.70.0100.08020.55
5.6.60.0000.07320.43
5.6.50.0100.06020.47
5.6.40.0030.07720.33
5.6.30.0100.04320.29
5.6.20.0100.07320.34
5.6.10.0100.07020.39
5.6.00.0030.08020.41
5.5.380.0030.08320.42
5.5.370.0030.09020.36
5.5.360.0100.07320.54
5.5.350.0130.07320.44
5.5.340.0070.08320.88
5.5.330.0070.08020.90
5.5.320.0070.08320.95
5.5.310.0070.07720.92
5.5.300.0030.09320.87
5.5.290.0100.08320.82
5.5.280.0130.08020.77
5.5.270.0130.07320.92
5.5.260.0070.08320.86
5.5.250.0170.07320.58
5.5.240.0130.06720.32
5.5.230.0030.04720.24
5.5.220.0070.07720.31
5.5.210.0030.08020.28
5.5.200.0100.07720.03
5.5.190.0100.07720.12
5.5.180.0200.06720.23
5.5.160.0100.07020.25
5.5.150.0070.04720.30
5.5.140.0070.07020.30
5.5.130.0070.07320.02
5.5.120.0170.05720.16
5.5.110.0070.07320.15
5.5.100.0100.07720.15
5.5.90.0030.08019.98
5.5.80.0030.08320.11
5.5.70.0070.07720.20
5.5.60.0130.07020.03
5.5.50.0030.07720.20
5.5.40.0130.04320.00
5.5.30.0200.05320.19
5.5.20.0130.04020.20
5.5.10.0130.07020.07
5.5.00.0100.03720.15
5.4.450.0030.08719.38
5.4.440.0100.07719.36
5.4.430.0070.08019.36
5.4.420.0170.07019.54
5.4.410.0100.07319.36
5.4.400.0030.07019.13
5.4.390.0100.07319.17
5.4.380.0070.05718.88
5.4.370.0130.05719.04
5.4.360.0130.07019.13
5.4.350.0070.04719.04
5.4.340.0130.07018.89
5.4.320.0100.06019.16
5.4.310.0030.05019.05
5.4.300.0030.05319.16
5.4.290.0030.08019.09
5.4.280.0000.07719.04
5.4.270.0030.07019.13
5.4.260.0070.05319.21
5.4.250.0070.07719.02
5.4.240.0070.07319.15
5.4.230.0070.06719.21
5.4.220.0100.07018.94
5.4.210.0030.08019.17
5.4.200.0100.07319.02
5.4.190.0030.07718.84
5.4.180.0100.07019.01
5.4.170.0100.07018.87
5.4.160.0000.08318.86
5.4.150.0070.07318.93
5.4.140.0030.07716.48
5.4.130.0000.07716.48
5.4.120.0030.07716.55
5.4.110.0070.07716.53
5.4.100.0070.06316.52
5.4.90.0000.08016.49
5.4.80.0070.07016.47
5.4.70.0030.06716.52
5.4.60.0030.07716.37
5.4.50.0070.05716.29
5.4.40.0030.07716.49
5.4.30.0100.07316.45
5.4.20.0000.04716.29
5.4.10.0030.07316.43
5.4.00.0030.07015.84
5.3.290.0030.06314.64
5.3.280.0130.04714.69
5.3.270.0130.07314.74
5.3.260.0030.07714.63
5.3.250.0170.07014.67
5.3.240.0070.07714.61
5.3.230.0030.07314.54
5.3.220.0130.06714.63
5.3.210.0070.06314.58
5.3.200.0000.05014.64
5.3.190.0100.07314.60
5.3.180.0070.07714.70
5.3.170.0100.07314.52
5.3.160.0100.07314.49
5.3.150.0100.07314.63
5.3.140.0070.07314.56
5.3.130.0070.03714.59
5.3.120.0030.05014.61
5.3.110.0130.06714.51
5.3.100.0100.06014.02
5.3.90.0000.08014.06
5.3.80.0130.06713.94
5.3.70.0070.06313.96
5.3.60.0070.07314.03
5.3.50.0070.06713.91
5.3.40.0100.06313.87
5.3.30.0130.06713.85
5.3.20.0070.06713.77
5.3.10.0030.07313.69
5.3.00.0030.05313.56
5.2.170.0070.06311.68
5.2.160.0070.06011.68
5.2.150.0000.05711.68
5.2.140.0030.06711.68
5.2.130.0070.05711.68
5.2.120.0100.06011.68
5.2.110.0130.03311.68
5.2.100.0100.05311.68
5.2.90.0100.04711.68
5.2.80.0030.05711.68
5.2.70.0100.06011.68
5.2.60.0030.06311.68
5.2.50.0070.05311.68
5.2.40.0030.06011.68
5.2.30.0000.06711.68
5.2.20.0030.06711.68
5.2.10.0000.06011.68
5.2.00.0100.05311.68
5.1.60.0100.04711.68
5.1.50.0000.05711.68
5.1.40.0030.05011.68
5.1.30.0030.05311.68
5.1.20.0030.05711.68
5.1.10.0030.05311.68
5.1.00.0030.03011.68
5.0.50.0030.04711.68
5.0.40.0070.04011.68
5.0.30.0070.05311.68
5.0.20.0000.04711.68
5.0.10.0000.04311.68
5.0.00.0000.06311.68
4.4.90.0070.03011.68
4.4.80.0030.03711.68
4.4.70.0030.03711.68
4.4.60.0100.03011.68
4.4.50.0100.03011.68
4.4.40.0070.04711.68
4.4.30.0070.03311.68
4.4.20.0030.03311.68
4.4.10.0000.03711.68
4.4.00.0030.05011.68
4.3.110.0000.03711.68
4.3.100.0030.03711.68
4.3.90.0000.03711.68
4.3.80.0070.05011.68
4.3.70.0030.03011.68
4.3.60.0000.03711.68
4.3.50.0030.03311.68
4.3.40.0000.04311.68
4.3.30.0030.03311.68
4.3.20.0030.03011.68
4.3.10.0000.03711.68
4.3.00.0000.03711.68

preferences:
42.29 ms | 401 KiB | 5 Q