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 ($source as $key => $value) { foreach ($drains as $gen) { $gen->send($value); } yield $key => $value; } } $receiver = function () { for (;;) { echo "TEE:\n"; print_r((yield)); } }; $receiver2 = function () { for (;;) { echo "Received!\n"; (yield); } }; $steps = [ function ($it) { foreach ($it as $val) { yield $val * 2; } }, "iterator_pass", ["iterator_chunk", 32], ["iterator_tee", [$receiver(), $receiver2()]] ]; $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.0110.00718.52
8.3.60.0120.00316.63
8.3.50.0220.00522.12
8.3.40.0120.00318.74
8.3.30.0100.01019.01
8.3.20.0040.00420.39
8.3.10.0040.00423.48
8.3.00.0070.00317.93
8.2.180.0150.00016.50
8.2.170.0150.00322.96
8.2.160.0100.00320.39
8.2.150.0000.00724.18
8.2.140.0090.00924.66
8.2.130.0040.00426.16
8.2.120.0060.00319.36
8.2.110.0030.00620.33
8.2.100.0060.00617.89
8.2.90.0040.00419.09
8.2.80.0040.00417.97
8.2.70.0040.00417.63
8.2.60.0040.00418.16
8.2.50.0050.00318.10
8.2.40.0030.00622.15
8.2.30.0070.00018.38
8.2.20.0000.00717.81
8.2.10.0030.00618.20
8.2.00.0040.00417.70
8.1.280.0120.00425.92
8.1.270.0030.00523.91
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0090.00021.43
8.1.230.0110.00317.85
8.1.220.0060.00317.79
8.1.210.0030.00618.77
8.1.200.0060.00317.25
8.1.190.0000.00817.35
8.1.180.0050.00318.10
8.1.170.0040.00418.61
8.1.160.0030.00622.05
8.1.150.0040.00418.71
8.1.140.0000.00817.36
8.1.130.0070.00019.22
8.1.120.0040.00417.39
8.1.110.0040.00417.47
8.1.100.0000.00717.49
8.1.90.0000.00717.52
8.1.80.0070.00017.47
8.1.70.0030.00317.41
8.1.60.0000.00817.63
8.1.50.0000.00817.43
8.1.40.0080.00017.45
8.1.30.0000.00917.64
8.1.20.0030.00617.74
8.1.10.0040.00417.61
8.1.00.0040.00417.43
8.0.300.0030.00818.77
8.0.290.0040.00416.88
8.0.280.0030.00318.47
8.0.270.0030.00317.32
8.0.260.0040.00418.48
8.0.250.0030.00417.00
8.0.240.0040.00717.09
8.0.230.0040.00417.07
8.0.220.0000.00716.96
8.0.210.0050.00317.00
8.0.200.0000.00717.06
8.0.190.0070.00017.05
8.0.180.0070.00016.97
8.0.170.0080.00017.03
8.0.160.0040.00417.06
8.0.150.0070.00316.93
8.0.140.0000.00816.99
8.0.130.0060.00013.34
8.0.120.0060.00316.98
8.0.110.0040.00417.04
8.0.100.0040.00416.86
8.0.90.0040.00416.92
8.0.80.0180.00316.93
8.0.70.0000.00716.96
8.0.60.0030.00516.95
8.0.50.0040.00416.86
8.0.30.0070.01417.31
8.0.20.0160.00817.43
8.0.10.0000.00717.05
8.0.00.0060.01316.84
7.4.330.0030.00315.00
7.4.320.0030.00316.61
7.4.300.0030.00316.69
7.4.290.0030.00616.52
7.4.280.0030.00516.63
7.4.270.0040.00416.55
7.4.260.0080.00016.61
7.4.250.0000.00716.60
7.4.240.0000.00716.53
7.4.230.0030.00316.37
7.4.220.0040.01516.63
7.4.210.0060.01216.70
7.4.200.0000.00716.56
7.4.160.0100.00616.75
7.4.150.0130.01017.40
7.4.140.0130.00417.86
7.4.130.0030.01616.48
7.4.120.0070.01216.58
7.4.110.0110.00616.50
7.4.100.0150.00616.53
7.4.90.0170.00016.57
7.4.80.0040.01819.39
7.4.70.0030.01416.69
7.4.60.0110.00816.63
7.4.50.0000.00816.36
7.4.40.0130.00616.56
7.4.30.0100.00616.56
7.4.00.0070.00915.07
7.3.330.0050.00013.49
7.3.320.0020.00213.37
7.3.310.0030.00316.49
7.3.300.0030.00316.32
7.3.290.0030.01216.42
7.3.280.0090.01116.48
7.3.270.0130.00617.40
7.3.260.0160.00316.82
7.3.250.0120.00716.57
7.3.240.0040.01516.63
7.3.230.0090.00916.47
7.3.210.0030.01416.61
7.3.200.0060.01019.39
7.3.190.0030.01316.47
7.3.180.0000.01516.48
7.3.170.0090.00916.50
7.3.160.0090.00816.48
7.3.120.0080.01014.92
7.3.110.0090.00614.96
7.3.100.0060.00915.09
7.3.90.0070.00914.90
7.3.80.0020.00914.86
7.3.70.0020.01214.73
7.3.60.0040.00914.97
7.3.50.0070.00914.97
7.3.40.0040.01114.96
7.3.30.0090.00214.81
7.3.20.0040.00916.71
7.3.10.0090.00616.77
7.3.00.0030.01016.76
7.2.330.0100.00716.86
7.2.320.0110.01116.48
7.2.310.0030.01316.64
7.2.300.0080.00816.85
7.2.290.0030.01316.86
7.2.250.0070.01214.97
7.2.240.0080.01215.07
7.2.230.0060.01115.21
7.2.220.0100.00415.16
7.2.210.0050.00815.15
7.2.200.0030.01315.06
7.2.190.0040.00915.09
7.2.180.0110.00314.87
7.2.170.0100.00615.13
7.2.160.0060.00314.88
7.2.150.0090.00616.93
7.2.140.0030.01316.97
7.2.130.0110.00316.96
7.2.120.0060.00616.76
7.2.110.0070.00716.75
7.2.100.0000.01017.14
7.2.90.0040.01516.98
7.2.80.0040.01416.92
7.2.70.0030.01016.96
7.2.60.0040.01117.06
7.2.50.0060.00316.81
7.2.40.0140.00016.98
7.2.30.0090.00316.84
7.2.20.0140.00417.02
7.2.10.0090.00316.95
7.2.00.0090.00518.13
7.1.330.0060.01015.80
7.1.320.0020.00915.87
7.1.310.0070.00615.74
7.1.300.0030.01115.90
7.1.290.0070.00815.70
7.1.280.0080.00415.86
7.1.270.0080.00515.78
7.1.260.0060.00615.80
7.1.250.0030.01215.78
7.1.240.0040.00815.83
7.1.230.0090.00615.77
7.1.220.0000.00915.82
7.1.210.0000.01115.78
7.1.200.0060.00715.67
7.1.190.0100.00315.46
7.1.180.0030.01215.93
7.1.170.0060.00615.80
7.1.160.0110.00015.83
7.1.150.0090.00315.58
7.1.140.0040.01115.69
7.1.130.0070.00715.57
7.1.120.0080.00415.71
7.1.110.0060.00915.68
7.1.100.0030.01016.85
7.1.90.0000.00915.57
7.1.80.0070.00716.04
7.1.70.0120.00616.40
7.1.60.0090.00817.75
7.1.50.0020.01116.54
7.1.40.0030.00915.84
7.1.30.0040.00815.73
7.1.20.0080.00515.78
7.1.10.0040.01115.94
7.1.00.0090.03919.11
7.0.330.0000.01415.64
7.0.320.0030.01015.19
7.0.310.0100.00615.39
7.0.300.0030.01015.18
7.0.290.0070.00715.18
7.0.280.0080.00815.52
7.0.270.0090.00615.43
7.0.260.0040.01115.27
7.0.250.0080.01115.16
7.0.240.0070.01115.48
7.0.230.0050.00515.37
7.0.220.0060.00915.43
7.0.210.0110.00415.63
7.0.200.0050.00716.03
7.0.190.0060.00615.50
7.0.180.0060.00615.55
7.0.170.0060.00915.52
7.0.160.0050.00515.14
7.0.150.0000.01315.47
7.0.140.0070.03818.85
7.0.130.0060.01015.21
7.0.120.0070.00715.58
7.0.110.0000.01015.28
7.0.100.0000.01415.54
7.0.90.0060.00915.54
7.0.80.0110.00715.54
7.0.70.0020.03018.46
7.0.60.0100.02318.47
7.0.50.0100.03318.83
7.0.40.0020.03116.75
7.0.30.0080.02616.79
7.0.20.0030.02616.78
7.0.10.0060.02216.80
7.0.00.0050.02516.68
5.6.400.0060.01214.54
5.6.390.0070.01014.55
5.6.380.0100.00314.39
5.6.370.0060.00914.50
5.6.360.0000.01614.52
5.6.350.0090.00914.53
5.6.340.0090.00914.82
5.6.330.0090.00614.70
5.6.320.0090.00914.47
5.6.310.0000.01714.77
5.6.300.0070.01114.93
5.6.290.0060.01314.24
5.6.280.0050.04017.78
5.6.270.0110.00714.41
5.6.260.0120.00314.35
5.6.250.0080.00414.41
5.6.240.0110.00414.36
5.6.230.0060.00614.45
5.6.220.0080.02017.41
5.6.210.0100.02017.60
5.6.200.0070.02517.87
5.6.190.0110.02317.85
5.6.180.0050.02517.79
5.6.170.0090.02217.80
5.6.160.0030.02717.78
5.6.150.0040.02617.69
5.6.140.0060.02517.84
5.6.130.0060.02317.87
5.6.120.0070.02317.69
5.6.110.0030.02517.79
5.6.100.0030.02917.73
5.6.90.0070.02317.70
5.6.80.0070.01917.54
5.6.70.0070.04517.44
5.6.60.0030.02517.57
5.6.50.0030.02517.42
5.6.40.0030.02617.31
5.6.30.0010.02617.44
5.6.20.0050.02717.34
5.6.10.0060.02317.41
5.6.00.0080.02317.39
5.5.380.0060.01314.29
5.5.370.0030.00914.46
5.5.360.0080.02417.45
5.5.350.0040.02617.54
5.5.340.0050.03117.64
5.5.330.0130.03817.73
5.5.320.0010.02817.60
5.5.310.0030.02817.62
5.5.300.0050.02317.58
5.5.290.0080.02517.48
5.5.280.0020.02717.71
5.5.270.0090.02217.53
5.5.260.0100.04317.80
5.5.250.0050.02317.44
5.5.240.0050.02317.26
5.5.230.0060.02317.28
5.5.220.0040.02417.31
5.5.210.0080.02017.16
5.5.200.0040.03117.36
5.5.190.0050.02417.34
5.5.180.0040.02417.27
5.5.170.0030.01014.56
5.5.160.0060.02317.24
5.5.150.0080.02717.18
5.5.140.0120.02017.36
5.5.130.0050.04717.11
5.5.120.0160.03517.19
5.5.110.0070.03817.30
5.5.100.0120.04217.25
5.5.90.0080.04317.23
5.5.80.0130.02517.22
5.5.70.0120.03017.36
5.5.60.0050.04317.12
5.5.50.0060.03817.23
5.5.40.0090.04217.37
5.5.30.0050.04517.29
5.5.20.0100.04517.35
5.5.10.0060.03417.23
5.5.00.0050.03317.10
5.4.450.0050.01815.83
5.4.440.0030.02215.71
5.4.430.0020.02015.78
5.4.420.0030.02415.70
5.4.410.0070.01515.70
5.4.400.0050.02015.69
5.4.390.0020.02915.68
5.4.380.0020.02315.65
5.4.370.0020.02315.62
5.4.360.0070.01815.57
5.4.350.0050.02015.62
5.4.340.0050.01515.68
5.4.330.0090.00312.20
5.4.320.0030.02515.67
5.4.310.0080.03615.55
5.4.300.0060.03815.71
5.4.290.0050.04215.68
5.4.280.0030.04015.57
5.4.270.0030.04015.61
5.4.260.0080.03715.71
5.4.250.0050.04215.54
5.4.240.0030.04515.62
5.4.230.0090.03815.53
5.4.220.0050.04415.68
5.4.210.0030.02815.70
5.4.200.0050.02915.61
5.4.190.0020.03415.64
5.4.180.0020.03715.72
5.4.170.0050.02915.71
5.4.160.0050.04515.53
5.4.150.0060.04115.60
5.4.140.0030.02914.36
5.4.130.0060.03814.33
5.4.120.0000.03314.33
5.4.110.0030.04114.38
5.4.100.0050.02014.39
5.4.90.0050.03714.31
5.4.80.0020.04014.31
5.4.70.0020.04214.33
5.4.60.0050.03514.30
5.4.50.0030.04014.35
5.4.40.0030.04014.35
5.4.30.0020.04014.24
5.4.20.0070.03714.26
5.4.10.0010.02914.26
5.4.00.0080.03114.07
5.3.290.0090.03513.44
5.3.280.0030.02813.45
5.3.270.0050.03913.44
5.3.260.0070.04313.40
5.3.250.0020.04213.37
5.3.240.0100.02913.47
5.3.230.0120.02913.41
5.3.220.0020.04113.35
5.3.210.0010.04113.40
5.3.200.0050.03813.45
5.3.190.0020.03313.41
5.3.180.0050.03013.37
5.3.170.0070.03713.35
5.3.160.0050.03713.40
5.3.150.0030.04313.40
5.3.140.0030.04513.36
5.3.130.0080.03813.38
5.3.120.0030.03813.34
5.3.110.0030.03213.41
5.3.100.0020.03113.18
5.3.90.0030.03813.13
5.3.80.0100.03713.18
5.3.70.0050.03813.17
5.3.60.0050.02013.05
5.3.50.0050.04013.02
5.3.40.0070.03413.13
5.3.30.0050.03413.09
5.3.20.0030.04212.91
5.3.10.0070.03812.90
5.3.00.0030.03912.95
5.2.170.0030.03312.19
5.2.160.0000.04712.19
5.2.150.0000.07012.19
5.2.140.0030.06312.19
5.2.130.0070.05712.19
5.2.120.0030.06312.19
5.2.110.0070.04312.19
5.2.100.0070.06012.19
5.2.90.0000.06312.19
5.2.80.0000.06312.19
5.2.70.0030.06312.19
5.2.60.0000.06712.19
5.2.50.0070.06012.19
5.2.40.0070.06012.19
5.2.30.0000.06712.19
5.2.20.0000.05012.19
5.2.10.0070.05312.19
5.2.00.0100.05312.19
5.1.60.0070.05012.19
5.1.50.0100.04712.19
5.1.40.0000.05712.19
5.1.30.0070.05712.19
5.1.20.0030.05312.19
5.1.10.0000.05712.19
5.1.00.0070.03712.19
5.0.50.0000.04712.19
5.0.40.0070.04012.19
5.0.30.0000.04712.19
5.0.20.0000.04312.19
5.0.10.0030.04712.19
5.0.00.0000.06712.19
4.4.90.0030.03312.19
4.4.80.0070.02312.19
4.4.70.0000.03712.19
4.4.60.0000.03712.19
4.4.50.0000.03712.19
4.4.40.0000.05312.19
4.4.30.0000.03312.19
4.4.20.0000.03712.19
4.4.10.0000.03012.19
4.4.00.0030.04712.19
4.3.110.0030.02712.19
4.3.100.0030.03012.19
4.3.90.0070.03012.19
4.3.80.0030.05012.19
4.3.70.0000.03712.19
4.3.60.0000.03012.19
4.3.50.0000.03712.19
4.3.40.0000.03712.19
4.3.30.0000.03712.19
4.3.20.0030.03712.19
4.3.10.0030.03012.19
4.3.00.0000.03712.19

preferences:
57.58 ms | 401 KiB | 5 Q