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 (;;) { 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.40.0060.01018.72
8.3.30.0070.00719.21
8.3.20.0000.00820.16
8.3.10.0080.00023.70
8.3.00.0030.00717.63
8.2.170.0090.00622.96
8.2.160.0120.00620.35
8.2.150.0040.00424.18
8.2.140.0030.00624.66
8.2.130.0070.01026.16
8.2.120.0050.00322.20
8.2.110.0060.00322.26
8.2.100.0080.00418.03
8.2.90.0000.00819.19
8.2.80.0030.00518.13
8.2.70.0040.00417.63
8.2.60.0040.00417.93
8.2.50.0060.00318.07
8.2.40.0050.00318.05
8.2.30.0060.00318.21
8.2.20.0000.00817.83
8.2.10.0000.00819.89
8.2.00.0100.00017.88
8.1.270.0060.00322.05
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0060.00323.84
8.1.230.0070.00419.15
8.1.220.0050.00317.74
8.1.210.0080.00018.77
8.1.200.0030.00617.36
8.1.190.0030.00617.40
8.1.180.0000.00818.10
8.1.170.0040.00418.48
8.1.160.0000.00722.07
8.1.150.0000.01118.67
8.1.140.0070.00017.50
8.1.130.0030.00317.90
8.1.120.0000.00717.53
8.1.110.0070.00017.37
8.1.100.0070.00017.49
8.1.90.0060.00317.34
8.1.80.0050.00317.56
8.1.70.0000.00717.48
8.1.60.0060.00317.62
8.1.50.0000.00817.50
8.1.40.0040.00417.43
8.1.30.0040.00417.65
8.1.20.0000.00817.68
8.1.10.0000.00817.48
8.1.00.0040.00417.61
8.0.300.0070.00318.77
8.0.290.0040.00417.05
8.0.280.0000.00818.41
8.0.270.0040.00317.29
8.0.260.0030.00317.39
8.0.250.0030.00316.98
8.0.240.0000.00717.05
8.0.230.0000.00716.98
8.0.220.0050.00316.98
8.0.210.0000.00716.95
8.0.200.0040.00417.09
8.0.190.0040.00417.07
8.0.180.0040.00417.05
8.0.170.0050.00217.02
8.0.160.0030.00516.96
8.0.150.0040.00416.95
8.0.140.0050.00316.97
8.0.130.0000.00513.41
8.0.120.0000.00816.93
8.0.110.0000.00716.82
8.0.100.0070.00016.95
8.0.90.0070.00016.87
8.0.80.0140.00017.03
8.0.70.0000.00717.05
8.0.60.0040.00417.05
8.0.50.0070.00017.04
8.0.30.0080.01017.26
8.0.20.0140.00617.40
8.0.10.0040.00416.90
8.0.00.0060.01116.72
7.4.330.0000.00515.00
7.4.320.0030.00316.71
7.4.300.0060.00016.61
7.4.290.0070.00016.57
7.4.280.0000.00816.66
7.4.270.0030.00316.67
7.4.260.0000.00716.62
7.4.250.0000.00716.48
7.4.240.0020.00516.56
7.4.230.0000.00716.65
7.4.220.0030.01616.66
7.4.210.0070.01016.60
7.4.200.0050.00216.44
7.4.190.0030.00316.68
7.4.160.0030.01216.41
7.4.150.0000.02617.40
7.4.140.0070.00917.86
7.4.130.0060.01116.47
7.4.120.0080.00916.41
7.4.110.0090.00916.49
7.4.100.0120.00616.47
7.4.90.0110.00716.57
7.4.80.0090.01219.39
7.4.70.0120.00316.43
7.4.60.0090.00916.61
7.4.50.0060.00316.43
7.4.40.0060.00922.77
7.4.30.0130.00316.69
7.4.00.0070.00715.15
7.3.330.0030.00313.32
7.3.320.0000.00513.48
7.3.310.0000.00816.46
7.3.300.0030.00516.55
7.3.290.0110.00316.39
7.3.280.0090.00916.46
7.3.270.0130.00317.40
7.3.260.0130.01016.39
7.3.250.0100.00916.55
7.3.240.0110.00616.68
7.3.230.0090.00916.52
7.3.210.0070.01716.71
7.3.200.0090.01219.39
7.3.190.0100.01316.39
7.3.180.0070.01016.34
7.3.170.0070.00716.49
7.3.160.0120.00916.71
7.3.120.0070.00714.84
7.2.330.0110.00716.76
7.2.320.0120.00616.82
7.2.310.0000.01616.68
7.2.300.0120.01216.76
7.2.290.0000.01716.64
7.2.60.0060.00916.71
7.2.00.0100.00319.63
7.1.200.0040.00815.75
7.1.100.0090.00318.02
7.1.70.0020.00516.91
7.1.60.0160.00719.33
7.1.50.0180.00916.92
7.1.00.0130.06722.50
7.0.200.0120.00616.51
7.0.140.0030.07722.05
7.0.110.0400.04020.09
7.0.100.0330.07019.99
7.0.90.0370.04719.96
7.0.80.0430.04319.96
7.0.70.0370.05019.94
7.0.60.0430.04019.93
7.0.50.0270.04019.99
7.0.40.0070.04319.74
7.0.30.0000.05019.85
7.0.20.0030.07019.72
7.0.10.0100.07719.78
7.0.00.0100.08019.70
5.6.280.0070.07321.19
5.6.260.0000.04320.73
5.6.250.0030.04020.58
5.6.240.0070.07020.68
5.6.230.0030.03720.70
5.6.220.0000.04720.88
5.6.210.0070.05720.71
5.6.200.0100.03320.74
5.6.190.0000.04720.60
5.6.180.0030.05320.68
5.6.170.0070.04320.68
5.6.160.0170.07020.73
5.6.150.0130.06020.59
5.6.140.0100.05020.68
5.6.130.0070.04720.48
5.6.120.0030.04720.60
5.6.110.0030.04320.68
5.6.100.0070.04320.57
5.6.90.0130.05020.58
5.6.80.0070.03720.00
5.6.70.0070.04020.09
5.6.60.0070.03720.05
5.6.50.0100.03319.89
5.6.40.0000.03719.99
5.6.30.0030.04320.03
5.6.20.0070.08319.94
5.6.10.0030.06320.05
5.6.00.0030.04020.04
5.5.380.0100.03317.59
5.5.370.0170.03017.70
5.5.360.0170.06017.53
5.5.350.0030.07017.58
5.5.340.0100.06318.08
5.5.330.0070.03718.23
5.5.320.0130.03718.08
5.5.310.0030.04017.92
5.5.300.0070.06018.14
5.5.290.0030.05018.22
5.5.280.0030.04718.11
5.5.270.0070.04018.10
5.5.260.0030.06017.95
5.5.250.0070.04717.91
5.5.240.0130.03017.54
5.5.230.0030.04017.33
5.5.220.0030.04017.32
5.5.210.0070.07317.62
5.5.200.0000.03717.47
5.5.190.0070.03717.40
5.5.180.0000.04317.20
5.5.160.0030.05017.45
5.5.150.0030.04317.27
5.5.140.0070.05317.29
5.5.130.0000.04317.22
5.5.120.0030.03317.29
5.5.110.0030.04017.57
5.5.100.0100.04317.48
5.5.90.0070.04317.37
5.5.80.0030.04717.40
5.5.70.0070.03717.35
5.5.60.0100.03017.30
5.5.50.0030.03317.45
5.5.40.0070.07017.36
5.5.30.0130.02717.09
5.5.20.0030.09717.29
5.5.10.0000.03717.17
5.5.00.0070.03317.31
5.4.450.0030.06319.64
5.4.440.0070.04019.27
5.4.430.0000.05719.48
5.4.420.0030.05319.36
5.4.410.0030.03719.38
5.4.400.0070.03719.18
5.4.390.0070.03719.01
5.4.380.0000.04019.00
5.4.370.0070.03719.00
5.4.360.0000.04318.99
5.4.350.0000.03719.31
5.4.340.0170.05319.03
5.4.320.0030.03719.06
5.4.310.0100.06718.99
5.4.300.0030.03719.18
5.4.290.0030.04019.22
5.4.280.0000.04018.98
5.4.270.0070.07019.14
5.4.260.0030.03719.02
5.4.250.0070.03019.00
5.4.240.0030.06019.22
5.4.230.0030.04019.01
5.4.220.0030.03319.13
5.4.210.0000.03719.13
5.4.200.0070.05319.00
5.4.190.0000.04019.22
5.4.180.0070.06019.00
5.4.170.0070.03018.97
5.4.160.0030.03719.04
5.4.150.0000.04719.23
5.4.140.0100.06716.39
5.4.130.0070.03016.58
5.4.120.0100.06716.54
5.4.110.0070.03016.46
5.4.100.0100.04316.62
5.4.90.0070.06016.62
5.4.80.0030.06016.61
5.4.70.0030.04716.46
5.4.60.0000.04016.52
5.4.50.0000.03716.44
5.4.40.0000.05716.29
5.4.30.0000.07316.52
5.4.20.0100.04716.54
5.4.10.0000.03316.56
5.4.00.0170.04715.97
5.3.290.0000.04314.69
5.3.280.0000.07314.71
5.3.270.0070.05014.70
5.3.260.0070.05714.63
5.3.250.0000.06314.74
5.3.240.0030.03714.69
5.3.230.0100.06314.56
5.3.220.0100.02714.65
5.3.210.0070.03014.70
5.3.200.0000.07714.70
5.3.190.0030.07314.56
5.3.180.0030.03714.80
5.3.170.0070.06314.80
5.3.160.0070.02714.57
5.3.150.0030.03714.66
5.3.140.0030.03714.58
5.3.130.0130.06014.51
5.3.120.0000.07714.70
5.3.110.0030.05014.70
5.3.100.0030.03314.28
5.3.90.0000.04014.06
5.3.80.0030.04714.01
5.3.70.0030.07314.02
5.3.60.0000.03714.01
5.3.50.0000.05313.98
5.3.40.0070.06314.18
5.3.30.0130.05713.92
5.3.20.0000.03313.71
5.3.10.0070.06013.68
5.3.00.0070.07013.80
5.2.170.0070.02312.13
5.2.160.0000.03012.13
5.2.150.0000.03712.13
5.2.140.0100.02312.13
5.2.130.0000.04712.13
5.2.120.0000.05712.13
5.2.110.0030.06712.13
5.2.100.0130.04312.13
5.2.90.0070.05712.13
5.2.80.0070.05712.13
5.2.70.0070.07012.13
5.2.60.0030.04312.13
5.2.50.0070.04712.13
5.2.40.0030.03312.13
5.2.30.0000.03712.13
5.2.20.0030.05712.13
5.2.10.0030.04012.13
5.2.00.0030.05312.13
5.1.60.0030.03012.13
5.1.50.0000.03312.13
5.1.40.0030.04712.13
5.1.30.0030.04012.13
5.1.20.0100.05712.13
5.1.10.0030.02712.13
5.1.00.0030.02712.13
5.0.50.0000.02312.13
5.0.40.0000.02712.13
5.0.30.0070.06012.13
5.0.20.0000.04012.13
5.0.10.0000.03312.13
5.0.00.0030.03012.13
4.4.90.0030.03012.13
4.4.80.0070.01712.13
4.4.70.0000.01712.13
4.4.60.0030.01712.13
4.4.50.0030.01712.13
4.4.40.0000.02712.13
4.4.30.0070.02712.13
4.4.20.0030.03012.13
4.4.10.0000.03012.13
4.4.00.0030.02712.13
4.3.110.0030.03012.13
4.3.100.0000.03712.13
4.3.90.0030.01312.13
4.3.80.0000.02712.13
4.3.70.0070.01312.13
4.3.60.0000.03012.13
4.3.50.0000.02312.13
4.3.40.0000.03712.13
4.3.30.0000.03712.13
4.3.20.0030.03012.13
4.3.10.0000.03312.13
4.3.00.0000.03012.13

preferences:
45.43 ms | 400 KiB | 5 Q