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; } } function iterator_tee(\Traversable $source, array $drains) { foreach ($it as $key => $value) { foreach ($drains as $gen) { $gen->send($value); } yield $key => $value; } } $receiver = function() { for (;;) { print_r((yield)); } }; $steps = [ function($it) { foreach ($it as $val) { yield $val * 2; } }, "iterator_pass", ["iterator_chunk", 32], ["iterator_tee", [$receiver]] ]; $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.70.0180.00018.52
8.3.60.0120.00318.68
8.3.50.0130.00221.93
8.3.40.0210.00018.96
8.3.30.0100.00318.67
8.3.20.0130.00318.79
8.3.10.0050.00321.04
8.3.00.0000.00721.76
8.2.180.0090.01216.62
8.2.170.0060.00922.96
8.2.160.0070.00720.52
8.2.150.0050.00324.18
8.2.140.0000.00924.66
8.2.130.0080.00026.16
8.2.120.0080.00021.16
8.2.110.0110.00020.39
8.2.100.0090.00318.03
8.2.90.0000.00819.38
8.2.80.0000.00818.04
8.2.70.0000.01117.63
8.2.60.0040.00418.04
8.2.50.0000.00818.07
8.2.40.0030.00518.00
8.2.30.0040.00419.77
8.2.20.0060.00317.78
8.2.10.0040.00417.84
8.2.00.0000.00817.63
8.1.280.0040.01125.92
8.1.270.0040.00423.99
8.1.260.0000.00826.35
8.1.250.0000.00728.09
8.1.240.0060.00322.42
8.1.230.0040.00820.89
8.1.220.0050.00318.77
8.1.210.0040.00418.83
8.1.200.0040.00817.35
8.1.190.0040.00417.43
8.1.180.0040.00418.10
8.1.170.0000.00818.63
8.1.160.0000.00718.82
8.1.150.0040.00418.57
8.1.140.0050.00317.57
8.1.130.0000.00717.75
8.1.120.0000.00717.46
8.1.110.0040.00417.47
8.1.100.0040.00417.38
8.1.90.0040.00417.43
8.1.80.0030.00517.49
8.1.70.0000.00717.45
8.1.60.0050.00317.61
8.1.50.0000.00717.41
8.1.40.0040.00417.54
8.1.30.0050.00317.68
8.1.20.0060.00317.60
8.1.10.0040.00417.61
8.1.00.0000.00817.54
8.0.300.0040.00419.79
8.0.290.0050.00217.18
8.0.280.0050.00318.53
8.0.270.0070.00017.30
8.0.260.0040.00416.97
8.0.250.0000.00816.91
8.0.240.0070.00417.02
8.0.230.0040.00417.05
8.0.220.0000.00916.99
8.0.210.0000.00816.95
8.0.200.0000.00717.07
8.0.190.0040.00416.95
8.0.180.0050.00216.94
8.0.170.0030.00616.95
8.0.160.0070.00016.96
8.0.150.0040.00416.95
8.0.140.0110.00016.82
8.0.130.0030.00313.45
8.0.120.0080.00016.79
8.0.110.0050.00216.99
8.0.100.0070.00016.98
8.0.90.0000.00716.89
8.0.80.0080.00817.03
8.0.70.0070.00016.87
8.0.60.0070.00016.86
8.0.50.0000.00716.97
8.0.30.0080.01417.03
8.0.20.0130.00717.40
8.0.10.0000.00717.06
8.0.00.0080.01017.01
7.4.330.0000.00514.66
7.4.320.0030.00316.67
7.4.300.0000.00716.53
7.4.290.0060.00016.63
7.4.280.0000.00816.54
7.4.270.0030.00316.50
7.4.260.0030.00313.32
7.4.250.0040.00416.48
7.4.240.0070.00016.65
7.4.230.0000.00716.51
7.4.220.0040.01516.63
7.4.210.0040.01316.57
7.4.200.0000.00716.41
7.4.190.0000.00716.55
7.4.160.0060.01016.36
7.4.150.0140.00317.40
7.4.140.0050.01517.86
7.4.130.0070.01116.63
7.4.120.0090.01116.61
7.4.110.0140.00316.70
7.4.100.0030.01416.63
7.4.90.0100.00716.66
7.4.80.0090.01319.37
7.4.70.0110.00616.48
7.4.60.0120.00616.62
7.4.50.0000.00816.43
7.4.40.0130.00322.52
7.4.30.0100.00616.66
7.4.00.0040.01114.94
7.3.330.0000.00613.46
7.3.320.0030.00313.41
7.3.310.0080.00016.51
7.3.300.0030.00316.33
7.3.290.0040.01116.47
7.3.280.0090.00816.42
7.3.270.0130.00317.40
7.3.260.0100.01018.24
7.3.250.0110.00916.46
7.3.240.0100.00716.39
7.3.230.0100.00716.45
7.3.210.0080.01616.49
7.3.200.0050.01119.39
7.3.190.0030.01416.54
7.3.180.0100.00616.68
7.3.170.0070.01316.48
7.3.160.0100.00716.55
7.3.120.0090.00614.74
7.3.10.0040.00716.42
7.3.00.0080.00316.76
7.2.330.0090.01016.93
7.2.320.0040.01616.56
7.2.310.0100.01416.85
7.2.300.0140.00416.91
7.2.290.0110.00616.74
7.2.130.0070.01016.71
7.2.120.0060.01017.10
7.2.110.0020.01116.93
7.2.100.0040.00816.89
7.2.90.0060.00617.05
7.2.80.0110.00416.84
7.2.70.0000.01216.72
7.2.60.0060.00616.80
7.2.50.0090.00616.85
7.2.40.0060.00616.95
7.2.30.0040.00717.13
7.2.20.0060.00316.59
7.2.10.0030.00617.01
7.2.00.0070.00718.21
7.1.250.0000.01015.70
7.1.100.0040.00718.24
7.1.70.0050.00217.15
7.1.60.0100.00619.40
7.1.50.0090.01216.91
7.1.00.0000.07022.36
7.0.200.0040.00416.68
7.0.140.0070.06721.92
7.0.70.0170.07720.03
7.0.60.0070.08320.01
7.0.50.0030.09020.35
7.0.40.0100.08020.18
7.0.30.0100.04020.07
7.0.20.0070.07020.14
7.0.10.0170.07020.14
7.0.00.0070.04020.16
5.6.280.0100.06721.09
5.6.220.0070.08720.51
5.6.210.0000.08320.78
5.6.200.0130.07721.10
5.6.190.0100.07721.07
5.6.180.0070.04021.09
5.6.170.0130.08021.06
5.6.160.0100.08320.98
5.6.150.0100.07720.96
5.6.140.0070.08021.05
5.6.130.0100.08021.04
5.6.120.0100.08321.04
5.6.110.0230.07021.04
5.6.100.0000.09021.03
5.6.90.0130.08321.04
5.6.80.0000.05020.48
5.6.70.0100.06320.50
5.6.60.0070.08020.46
5.6.50.0100.05320.45
5.6.40.0000.09020.41
5.6.30.0170.07320.43
5.6.20.0030.08720.39
5.6.10.0030.08320.39
5.6.00.0030.05720.31
5.5.360.0100.06720.42
5.5.350.0070.08720.41
5.5.340.0130.05320.78
5.5.330.0000.09320.82
5.5.320.0030.05720.88
5.5.310.0100.07720.89
5.5.300.0000.07020.63
5.5.290.0100.07720.65
5.5.280.0100.07720.75
5.5.270.0030.04720.65
5.5.260.0200.07020.93
5.5.250.0170.05720.61
5.5.240.0100.08320.13
5.5.230.0170.06720.28
5.5.220.0130.07720.20
5.5.210.0130.08020.22
5.5.200.0100.04720.23
5.5.190.0200.07020.10
5.5.180.0130.08020.28
5.5.160.0070.07720.22
5.5.150.0000.08320.29
5.5.140.0030.08320.25
5.5.130.0130.06020.14
5.5.120.0030.06020.09
5.5.110.0130.07720.16
5.5.100.0130.07020.18
5.5.90.0100.05020.16
5.5.80.0170.08019.99
5.5.70.0130.07720.08
5.5.60.0030.04020.05
5.5.50.0100.03320.21
5.5.40.0000.04720.07
5.5.30.0000.04720.07
5.5.20.0030.04020.07
5.5.10.0170.06320.07
5.5.00.0100.03720.07
5.4.450.0100.07319.42
5.4.440.0130.06319.37
5.4.430.0100.07719.45
5.4.420.0000.04719.22
5.4.410.0030.08319.32
5.4.400.0100.06019.05
5.4.390.0070.08019.13
5.4.380.0130.07319.05
5.4.370.0100.07719.05
5.4.360.0030.06019.03
5.4.350.0130.07319.13
5.4.340.0030.08319.09
5.4.320.0130.07719.03
5.4.310.0070.07019.20
5.4.300.0030.05318.94
5.4.290.0230.06319.23
5.4.280.0170.07019.03
5.4.270.0070.08019.13
5.4.260.0030.08018.94
5.4.250.0030.04719.09
5.4.240.0100.07019.23
5.4.230.0030.08319.13
5.4.220.0000.04019.11
5.4.210.0030.04018.84
5.4.200.0000.04319.13
5.4.190.0070.03318.86
5.4.180.0070.05319.02
5.4.170.0000.04319.02
5.4.160.0000.04018.83
5.4.150.0000.05019.18
5.4.140.0030.03716.49
5.4.130.0030.04016.46
5.4.120.0130.06016.49
5.4.110.0070.05016.40
5.4.100.0070.03316.48
5.4.90.0070.03316.55
5.4.80.0070.05316.45
5.4.70.0070.07316.51
5.4.60.0070.04316.33
5.4.50.0000.03716.48
5.4.40.0070.03716.39
5.4.30.0070.03316.52
5.4.20.0030.04016.36
5.4.10.0030.03716.41
5.4.00.0070.03315.94
5.3.290.0100.05314.66
5.3.280.0030.04314.53
5.3.270.0000.04014.60
5.3.260.0030.04014.62
5.3.250.0100.04314.58
5.3.240.0030.03714.54
5.3.230.0100.03314.55
5.3.220.0100.04714.49
5.3.210.0100.08314.56
5.3.200.0000.04014.56
5.3.190.0000.04314.50
5.3.180.0000.05014.69
5.3.170.0070.06714.52
5.3.160.0000.04014.68
5.3.150.0030.03714.63
5.3.140.0000.04014.55
5.3.130.0030.04014.61
5.3.120.0130.05014.54
5.3.110.0030.04014.56
5.3.100.0100.03014.16
5.3.90.0030.03714.06
5.3.80.0000.04014.11
5.3.70.0030.04314.05
5.3.60.0100.07014.02
5.3.50.0070.03313.96
5.3.40.0070.04013.86
5.3.30.0030.03713.97
5.3.20.0000.04013.71
5.3.10.0070.03013.80
5.3.00.0070.03313.65
5.2.170.0030.03012.25
5.2.160.0030.02712.25
5.2.150.0000.05012.25
5.2.140.0030.04312.25
5.2.130.0070.05712.25
5.2.120.0030.05312.25
5.2.110.0000.03012.25
5.2.100.0030.02712.25
5.2.90.0000.03012.25
5.2.80.0030.03712.25
5.2.70.0000.03712.25
5.2.60.0070.03012.25
5.2.50.0100.02312.25
5.2.40.0030.02712.25
5.2.30.0030.02712.25
5.2.20.0000.03012.25
5.2.10.0000.05012.25
5.2.00.0030.03312.25
5.1.60.0030.02312.25
5.1.50.0070.02312.25
5.1.40.0130.04712.25
5.1.30.0030.05712.25
5.1.20.0100.05712.25
5.1.10.0030.06012.25
5.1.00.0070.05012.25
5.0.50.0100.03012.25
5.0.40.0030.04312.25
5.0.30.0030.06012.25
5.0.20.0100.03012.25
5.0.10.0070.04012.25
5.0.00.0100.05712.25
4.4.90.0000.01712.25
4.4.80.0070.02012.25
4.4.70.0000.01712.25
4.4.60.0000.01712.25
4.4.50.0030.01712.25
4.4.40.0000.02712.25
4.4.30.0000.01712.25
4.4.20.0070.03312.25
4.4.10.0070.03312.25
4.4.00.0100.04712.25
4.3.110.0030.03712.25
4.3.100.0030.03312.25
4.3.90.0000.03712.25
4.3.80.0000.03712.25
4.3.70.0030.03312.25
4.3.60.0030.02712.25
4.3.50.0030.02312.25
4.3.40.0000.05312.25
4.3.30.0030.03712.25
4.3.20.0030.03012.25
4.3.10.0030.02712.25
4.3.00.0030.02312.25

preferences:
40.52 ms | 401 KiB | 5 Q