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, array $steps) { $gen = $source; foreach ($steps as $spec) { if (is_array($spec) and !is_callable($spec)) { $g = array_shift($spec); array_unshift($spec, $gen); if (class_exists($g)) { $class = new \ReflectionClass($className); $gen = $class->newInstanceArgs($spec); } else if (is_callable($g)) { $gen = call_user_func_array($g, $spec); } } else if (is_callable($spec)) { $gen = $spec($gen); } } return $gen; } function iterator_chunk(\Traversable $it, $chunkSize) { $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.60.0070.00718.56
8.3.50.0050.01021.90
8.3.40.0180.00018.84
8.3.30.0120.00919.18
8.3.20.0000.00820.33
8.3.10.0080.00021.92
8.3.00.0000.01022.35
8.2.180.0110.00418.54
8.2.170.0060.00922.96
8.2.160.0110.00321.02
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0090.00019.36
8.2.110.0000.00922.13
8.2.100.0080.00317.84
8.2.90.0050.00319.04
8.2.80.0030.00518.03
8.2.70.0040.00417.75
8.2.60.0000.00817.93
8.2.50.0000.00918.07
8.2.40.0100.00018.09
8.2.30.0030.00618.19
8.2.20.0000.00817.78
8.2.10.0030.00517.84
8.2.00.0050.00217.75
8.1.280.0170.00325.92
8.1.270.0040.00423.97
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00323.80
8.1.230.0040.00818.88
8.1.220.0090.00017.74
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0000.00817.51
8.1.180.0030.00518.10
8.1.170.0060.00318.61
8.1.160.0040.00422.01
8.1.150.0040.00418.56
8.1.140.0040.00417.37
8.1.130.0000.00717.75
8.1.120.0040.00417.52
8.1.110.0040.00417.42
8.1.100.0040.00417.45
8.1.90.0050.00217.53
8.1.80.0000.00717.32
8.1.70.0000.00717.39
8.1.60.0040.00617.48
8.1.50.0040.00417.42
8.1.40.0040.00417.48
8.1.30.0030.00617.60
8.1.20.0030.00517.61
8.1.10.0040.00417.58
8.1.00.0030.00517.54
8.0.300.0040.00418.77
8.0.290.0000.00817.05
8.0.280.0000.00718.48
8.0.270.0040.00417.29
8.0.260.0030.00316.84
8.0.250.0040.00417.09
8.0.240.0050.00317.04
8.0.230.0070.00017.04
8.0.220.0000.00716.94
8.0.210.0030.00416.95
8.0.200.0000.00717.00
8.0.190.0000.00817.07
8.0.180.0000.00717.00
8.0.170.0040.00416.98
8.0.160.0040.00416.86
8.0.150.0040.00416.80
8.0.140.0040.00416.84
8.0.130.0030.00313.43
8.0.120.0000.00816.98
8.0.110.0040.00417.00
8.0.100.0050.00316.81
8.0.90.0040.00416.89
8.0.80.0100.00717.04
8.0.70.0040.00416.93
8.0.60.0040.00416.96
8.0.50.0040.00416.92
8.0.30.0050.01417.34
8.0.20.0120.00617.40
8.0.10.0040.00417.07
8.0.00.0080.01516.88
7.4.330.0000.00515.00
7.4.320.0040.00416.66
7.4.300.0030.00316.61
7.4.290.0040.00416.59
7.4.280.0040.00416.57
7.4.270.0030.00316.63
7.4.260.0000.00716.51
7.4.250.0020.00516.48
7.4.240.0040.00416.59
7.4.230.0080.00016.56
7.4.220.0130.01316.70
7.4.210.0120.00316.57
7.4.200.0000.00716.66
7.4.190.0040.00416.69
7.4.160.0030.01416.56
7.4.150.0110.00817.40
7.4.140.0060.01217.86
7.4.130.0120.00616.50
7.4.120.0090.00916.39
7.4.110.0130.00416.36
7.4.100.0060.01516.55
7.4.90.0100.00716.54
7.4.80.0090.00916.38
7.4.70.0130.00716.57
7.4.60.0130.01016.58
7.4.50.0000.00816.61
7.4.40.0040.01122.77
7.4.30.0000.01816.35
7.4.10.0000.01615.13
7.4.00.0090.00715.10
7.3.330.0050.00013.39
7.3.320.0030.00313.23
7.3.310.0070.00016.50
7.3.300.0030.00316.36
7.3.290.0110.00316.45
7.3.280.0060.01116.44
7.3.270.0110.00617.40
7.3.260.0100.02016.47
7.3.250.0070.01416.57
7.3.240.0030.01816.43
7.3.230.0100.01316.53
7.3.210.0070.01716.45
7.3.200.0100.00919.39
7.3.190.0090.00916.43
7.3.180.0070.01016.39
7.3.170.0130.00316.54
7.3.160.0070.01016.38
7.3.130.0060.01014.75
7.3.120.0070.00814.82
7.3.110.0130.00714.73
7.3.100.0030.01014.93
7.3.90.0060.01314.92
7.3.80.0030.01014.82
7.3.70.0100.00714.92
7.3.60.0090.00914.84
7.3.50.0110.00714.72
7.3.40.0070.00414.95
7.3.30.0040.01114.93
7.3.20.0060.00916.67
7.3.10.0030.01316.42
7.3.00.0040.01116.61
7.2.330.0070.01116.73
7.2.320.0120.00616.65
7.2.310.0100.01416.73
7.2.300.0070.01116.92
7.2.290.0130.00716.57
7.2.260.0100.01014.96
7.2.250.0070.01415.10
7.2.240.0070.00715.11
7.2.230.0110.00414.89
7.2.220.0040.01215.18
7.2.210.0040.01114.80
7.2.200.0120.00615.25
7.2.190.0130.00715.20
7.2.180.0040.01115.34
7.2.170.0060.00615.30
7.2.160.0120.00615.13
7.2.150.0060.00917.05
7.2.140.0040.00416.82
7.2.130.0040.00716.96
7.2.120.0120.00316.94
7.2.110.0070.01116.84
7.2.100.0070.00416.68
7.2.90.0030.01116.73
7.2.80.0070.00416.84
7.2.70.0000.01617.02
7.2.60.0090.00617.10
7.2.50.0110.00616.89
7.2.40.0030.00616.80
7.2.30.0030.01117.06
7.2.20.0030.00716.91
7.2.10.0100.00617.06
7.2.00.0100.00316.93
7.1.330.0030.00715.76
7.1.320.0060.00615.48
7.1.310.0040.00715.76
7.1.300.0130.00315.78
7.1.290.0060.00315.90
7.1.280.0000.01515.66
7.1.270.0030.00615.75
7.1.260.0050.00515.54
7.1.250.0060.00315.82
7.1.240.0060.00915.75
7.1.230.0030.00615.91
7.1.220.0060.00915.77
7.1.210.0070.00715.51
7.1.200.0060.00615.82
7.1.190.0030.01016.01
7.1.180.0060.00815.75
7.1.170.0040.01115.54
7.1.160.0030.00915.94
7.1.150.0000.01115.98
7.1.140.0040.01215.73
7.1.130.0040.00715.50
7.1.120.0040.01115.91
7.1.110.0090.00015.88
7.1.100.0040.00917.05
7.1.90.0000.00915.71
7.1.80.0000.01015.78
7.1.70.0040.00516.38
7.1.60.0080.01217.86
7.1.50.0080.01016.49
7.1.40.0060.00615.54
7.1.30.0030.01015.79
7.1.20.0100.00315.89
7.1.10.0090.00615.98
7.1.00.0020.04419.09
7.0.330.0030.01215.40
7.0.320.0060.00915.16
7.0.310.0130.00015.61
7.0.300.0000.01615.47
7.0.290.0030.01315.26
7.0.280.0000.01215.44
7.0.270.0040.01115.27
7.0.260.0040.01115.46
7.0.250.0070.00715.53
7.0.240.0100.00615.59
7.0.230.0090.00315.38
7.0.220.0000.01315.43
7.0.210.0030.00915.64
7.0.200.0020.01116.28
7.0.190.0030.01215.33
7.0.180.0000.01215.45
7.0.170.0070.00715.23
7.0.160.0030.01315.27
7.0.150.0000.01615.36
7.0.140.0090.03518.81
7.0.130.0080.00415.30
7.0.120.0100.00315.35
7.0.110.0100.00315.46
7.0.100.0120.04017.67
7.0.90.0100.03717.71
7.0.80.0050.04317.87
7.0.70.0100.01517.70
7.0.60.0110.04317.70
7.0.50.0160.04517.97
7.0.40.0050.03616.74
7.0.30.0070.02016.69
7.0.20.0050.02416.63
7.0.10.0080.02716.72
7.0.00.0090.03016.79
5.6.400.0070.01114.35
5.6.390.0040.01414.69
5.6.380.0030.01314.26
5.6.370.0070.01014.28
5.6.360.0060.00914.45
5.6.350.0090.00914.76
5.6.340.0070.01014.41
5.6.330.0090.00614.74
5.6.320.0100.00714.84
5.6.310.0150.00314.71
5.6.300.0100.01014.11
5.6.290.0000.01114.25
5.6.280.0090.04917.67
5.6.270.0070.01014.74
5.6.260.0180.00714.58
5.6.250.0110.03117.46
5.6.240.0050.02617.48
5.6.230.0020.02517.53
5.6.220.0060.02017.60
5.6.210.0030.02517.64
5.6.200.0050.04317.75
5.6.190.0090.04317.79
5.6.180.0050.04817.74
5.6.170.0090.02717.72
5.6.160.0090.04617.76
5.6.150.0070.03217.75
5.6.140.0040.05117.79
5.6.130.0030.03017.68
5.6.120.0100.03017.79
5.6.110.0070.03617.79
5.6.100.0080.03017.75
5.6.90.0050.03617.80
5.6.80.0050.04517.35
5.6.70.0050.04517.45
5.6.60.0070.02817.42
5.6.50.0100.02217.60
5.6.40.0090.03517.56
5.6.30.0090.02617.33
5.6.20.0150.01817.56
5.6.10.0030.02517.35
5.6.00.0070.03617.36
5.5.380.0080.02317.45
5.5.370.0060.02117.38
5.5.360.0050.04617.44
5.5.350.0120.03217.44
5.5.340.0050.04517.75
5.5.330.0080.03517.73
5.5.320.0030.04717.61
5.5.310.0060.03317.74
5.5.300.0070.03517.62
5.5.290.0050.02817.82
5.5.280.0130.03417.50
5.5.270.0070.02717.89
5.5.260.0050.03717.85
5.5.250.0050.02417.55
5.5.240.0080.05117.35
5.5.230.0080.04817.32
5.5.220.0080.04617.24
5.5.210.0090.03217.29
5.5.200.0070.04117.33
5.5.190.0080.02017.38
5.5.180.0110.03617.38
5.5.170.0090.00614.26
5.5.160.0070.02517.32
5.5.150.0050.02217.16
5.5.140.0050.04917.43
5.5.130.0050.04517.24
5.5.120.0130.02217.33
5.5.110.0120.04117.42
5.5.100.0080.04117.39
5.5.90.0060.03817.12
5.5.80.0030.03517.10
5.5.70.0070.03917.03
5.5.60.0160.02117.27
5.5.50.0030.02717.20
5.5.40.0100.02517.29
5.5.30.0050.03917.35
5.5.20.0030.04817.13
5.5.10.0100.02617.38
5.5.00.0100.03117.32
5.4.450.0020.04416.22
5.4.440.0000.02616.17
5.4.430.0020.02316.21
5.4.420.0050.04316.12
5.4.410.0050.01816.14
5.4.400.0060.01916.09
5.4.390.0070.03616.05
5.4.380.0070.04116.04
5.4.370.0050.04216.07
5.4.360.0070.01815.97
5.4.350.0090.01516.04
5.4.340.0050.04315.96
5.4.330.0070.00012.97
5.4.320.0030.02015.93
5.4.310.0050.03216.00
5.4.300.0100.03016.05
5.4.290.0020.02315.93
5.4.280.0100.04115.96
5.4.270.0050.02116.00
5.4.260.0030.02816.07
5.4.250.0070.03015.90
5.4.240.0040.04115.93
5.4.230.0030.03616.05
5.4.220.0090.02416.05
5.4.210.0000.03715.90
5.4.200.0060.04616.03
5.4.190.0070.04215.99
5.4.180.0050.04016.07
5.4.170.0050.03816.09
5.4.160.0050.01816.00
5.4.150.0020.03016.04
5.4.140.0060.03214.68
5.4.130.0050.01614.71
5.4.120.0070.01814.71
5.4.110.0040.03314.73
5.4.100.0060.03414.76
5.4.90.0060.01814.71
5.4.80.0050.01914.75
5.4.70.0030.03714.71
5.4.60.0020.02714.68
5.4.50.0030.04314.65
5.4.40.0030.02214.73
5.4.30.0080.02314.71
5.4.20.0070.03614.66
5.4.10.0060.03214.73
5.4.00.0050.01714.38
5.3.290.0040.02114.06
5.3.280.0080.03314.06
5.3.270.0050.03314.06
5.3.260.0030.04514.06
5.3.250.0050.03514.06
5.3.240.0050.02514.06
5.3.230.0020.02714.06
5.3.220.0030.02314.06
5.3.210.0060.03314.06
5.3.200.0030.02314.06
5.3.190.0050.04214.06
5.3.180.0000.02714.06
5.3.170.0030.03514.06
5.3.160.0050.02614.06
5.3.150.0050.02214.06
5.3.140.0130.01614.06
5.3.130.0020.02014.06
5.3.120.0000.03614.06
5.3.110.0030.02014.06
5.3.100.0080.02314.06
5.3.90.0050.02714.06
5.3.80.0100.01314.06
5.3.70.0010.02114.06
5.3.60.0020.02014.06
5.3.50.0030.03114.06
5.3.40.0090.01314.06
5.3.30.0030.02114.06
5.3.20.0020.02114.06
5.3.10.0020.01814.06
5.3.00.0020.02014.06
5.2.170.0000.02715.15
5.2.160.0030.03315.15
5.2.150.0030.03015.15
5.2.140.0030.02715.15
5.2.130.0000.03015.15
5.2.120.0100.04315.15
5.2.110.0030.02715.15
5.2.100.0070.05715.15
5.2.90.0070.04315.15
5.2.80.0000.05715.15
5.2.70.0070.05715.15
5.2.60.0070.02715.15
5.2.50.0000.05015.15
5.2.40.0030.03015.15
5.2.30.0000.02715.15
5.2.20.0030.04015.15
5.2.10.0030.02315.15
5.2.00.0030.03315.15
5.1.60.0030.03315.15
5.1.50.0030.02315.15
5.1.40.0000.02715.15
5.1.30.0070.02715.15
5.1.20.0030.04015.15
5.1.10.0000.05015.15
5.1.00.0030.04715.15
5.0.50.0030.04315.15
5.0.40.0030.03315.15
5.0.30.0000.07715.15
5.0.20.0000.01715.15
5.0.10.0000.03715.15
5.0.00.0000.03715.15
4.4.90.0000.01715.15
4.4.80.0100.02715.15
4.4.70.0000.01315.15
4.4.60.0000.02015.15
4.4.50.0000.01315.15
4.4.40.0000.03315.15
4.4.30.0000.01715.15
4.4.20.0000.03015.15
4.4.10.0030.03315.15
4.4.00.0030.04315.15
4.3.110.0030.01315.15
4.3.100.0000.03015.15
4.3.90.0000.02715.15
4.3.80.0070.02015.15
4.3.70.0070.01315.15
4.3.60.0070.01015.15
4.3.50.0030.03015.15
4.3.40.0000.02015.15
4.3.30.0030.01715.15
4.3.20.0030.01315.15
4.3.10.0000.04015.15
4.3.00.0030.03315.15

preferences:
30.81 ms | 401 KiB | 5 Q