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); } }; $source = function() { for ($i = 0; $i <= 127; $i++) { yield $i; } }; $steps = [ function ($it) { foreach ($it as $val) { yield $val * 2; } }, "iterator_pass", ["iterator_chunk", 32], ["iterator_tee", [$receiver(), $receiver2()]] ]; $it = iterator_pipeline($source(), $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.0090.00618.41
8.3.50.0100.00822.06
8.3.40.0090.00618.84
8.3.30.0120.00619.27
8.3.20.0070.00720.16
8.3.10.0040.00422.09
8.3.00.0040.00422.44
8.2.180.0120.00316.50
8.2.170.0110.00422.96
8.2.160.0100.00320.97
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0080.00426.16
8.2.120.0090.00019.48
8.2.110.0100.00022.13
8.2.100.0040.00817.97
8.2.90.0030.00519.16
8.2.80.0000.00817.97
8.2.70.0090.00017.50
8.2.60.0030.00618.03
8.2.50.0080.00018.07
8.2.40.0030.00618.22
8.2.30.0000.00718.12
8.2.20.0070.00017.67
8.2.10.0040.00417.84
8.2.00.0060.00317.69
8.1.280.0030.01025.92
8.1.270.0080.00023.79
8.1.260.0030.00726.35
8.1.250.0000.00728.09
8.1.240.0090.00024.02
8.1.230.0090.00319.16
8.1.220.0040.00417.76
8.1.210.0050.00518.77
8.1.200.0060.00317.38
8.1.190.0040.00417.66
8.1.180.0000.00818.10
8.1.170.0030.00618.71
8.1.160.0040.00422.07
8.1.150.0080.00018.76
8.1.140.0060.00317.37
8.1.130.0030.00317.78
8.1.120.0050.00217.48
8.1.110.0050.00217.38
8.1.100.0040.00417.39
8.1.90.0040.00417.48
8.1.80.0040.00417.43
8.1.70.0030.00317.46
8.1.60.0050.00317.61
8.1.50.0030.00517.46
8.1.40.0000.00817.52
8.1.30.0080.00017.59
8.1.20.0030.00617.57
8.1.10.0040.00417.57
8.1.00.0000.00717.48
8.0.300.0000.00718.77
8.0.290.0070.00017.05
8.0.280.0020.00518.38
8.0.270.0030.00317.22
8.0.260.0070.00416.83
8.0.250.0030.00316.99
8.0.240.0050.00216.92
8.0.230.0040.00417.05
8.0.220.0030.00316.99
8.0.210.0030.00616.85
8.0.200.0030.00317.00
8.0.190.0040.00417.07
8.0.180.0000.00716.99
8.0.170.0080.00017.03
8.0.160.0000.00716.92
8.0.150.0040.00317.00
8.0.140.0000.00716.93
8.0.130.0000.00613.35
8.0.120.0000.00816.96
8.0.110.0000.00816.87
8.0.100.0040.00416.91
8.0.90.0060.00316.83
8.0.80.0120.00916.96
8.0.70.0050.00217.01
8.0.60.0040.00416.96
8.0.50.0040.00416.99
8.0.30.0130.00717.14
8.0.20.0090.01017.40
8.0.10.0000.00717.01
8.0.00.0120.01216.73
7.4.330.0070.00015.14
7.4.320.0030.00316.38
7.4.300.0070.00016.52
7.4.290.0030.00316.63
7.4.280.0000.00716.62
7.4.270.0000.00716.63
7.4.260.0080.00016.49
7.4.250.0040.00416.61
7.4.240.0040.00416.45
7.4.230.0070.00016.71
7.4.220.0130.01016.64
7.4.210.0100.00716.63
7.4.200.0000.00716.57
7.4.190.0000.00716.57
7.4.160.0100.00716.30
7.4.150.0040.01417.40
7.4.140.0110.00817.86
7.4.130.0100.00816.51
7.4.120.0110.00616.47
7.4.110.0100.00716.52
7.4.100.0120.00616.57
7.4.90.0120.00616.45
7.4.80.0070.01416.59
7.4.70.0120.00616.55
7.4.60.0050.01316.20
7.4.50.0000.00816.66
7.4.40.0090.00622.77
7.4.30.0130.00716.45
7.4.10.0060.01115.55
7.4.00.0070.00815.27
7.3.330.0000.00613.40
7.3.320.0050.00013.53
7.3.310.0040.00416.52
7.3.300.0030.00316.48
7.3.290.0080.00816.48
7.3.280.0080.00716.46
7.3.270.0090.00917.40
7.3.260.0030.01616.58
7.3.250.0090.00916.52
7.3.240.0100.00716.48
7.3.230.0030.01616.47
7.3.210.0110.00716.51
7.3.200.0130.00619.39
7.3.190.0140.00416.59
7.3.180.0000.01816.27
7.3.170.0070.01016.68
7.3.160.0110.00716.47
7.3.130.0040.00915.70
7.3.120.0070.00915.38
7.3.110.0060.01015.46
7.3.100.0090.00615.49
7.3.90.0060.01015.42
7.3.80.0020.01015.58
7.3.70.0040.01015.34
7.3.60.0050.00915.46
7.3.50.0060.00715.36
7.3.40.0090.00515.34
7.3.30.0010.01215.43
7.3.20.0090.00317.30
7.3.10.0030.00917.24
7.3.00.0050.00917.06
7.2.330.0130.00616.63
7.2.320.0030.01516.50
7.2.310.0060.01416.72
7.2.300.0100.00716.82
7.2.290.0160.00616.60
7.2.260.0110.01015.98
7.2.250.0070.01215.59
7.2.240.0050.01215.65
7.2.230.0090.00615.62
7.2.220.0050.00815.58
7.2.210.0070.01015.76
7.2.200.0070.00615.71
7.2.190.0010.01415.57
7.2.180.0090.00515.60
7.2.170.0050.00715.68
7.2.160.0030.01215.80
7.2.150.0030.01017.67
7.2.140.0060.00717.69
7.2.130.0050.00917.81
7.2.120.0030.01017.67
7.2.110.0030.01017.77
7.2.100.0080.00717.74
7.2.90.0050.00717.67
7.2.80.0060.00617.71
7.2.70.0070.00917.73
7.2.60.0080.00717.58
7.2.50.0060.01217.66
7.2.40.0050.00817.72
7.2.30.0090.00717.62
7.2.20.0050.00617.75
7.2.10.0050.00717.54
7.2.00.0050.00918.13
7.1.330.0030.01116.25
7.1.320.0080.00716.26
7.1.310.0050.00916.33
7.1.300.0060.01116.38
7.1.290.0080.00616.36
7.1.280.0050.00716.36
7.1.270.0060.00816.36
7.1.260.0070.00516.10
7.1.250.0050.00716.55
7.1.240.0060.00816.40
7.1.230.0020.01116.43
7.1.220.0040.01216.51
7.1.210.0040.00916.58
7.1.200.0030.00816.29
7.1.190.0080.00816.59
7.1.180.0020.01316.57
7.1.170.0060.00816.51
7.1.160.0050.00816.53
7.1.150.0020.00916.49
7.1.140.0060.00616.63
7.1.130.0040.00916.54
7.1.120.0060.00816.55
7.1.110.0050.00916.51
7.1.100.0080.00917.04
7.1.90.0020.01116.60
7.1.80.0020.01016.58
7.1.70.0050.00616.81
7.1.60.0070.00917.62
7.1.50.0060.00816.76
7.1.40.0050.01016.49
7.1.30.0080.00516.60
7.1.20.0070.00616.54
7.1.10.0050.00916.57
7.1.00.0040.03218.43
7.0.330.0040.00716.17
7.0.320.0060.00816.26
7.0.310.0060.00816.17
7.0.300.0110.00316.09
7.0.290.0050.00816.14
7.0.280.0030.00816.13
7.0.270.0030.01316.09
7.0.260.0020.01316.32
7.0.250.0020.01116.12
7.0.240.0130.00616.18
7.0.230.0090.00516.18
7.0.220.0040.00916.12
7.0.210.0050.01116.35
7.0.200.0080.00816.39
7.0.190.0060.00816.21
7.0.180.0030.01116.19
7.0.170.0110.00316.07
7.0.160.0100.00516.17
7.0.150.0110.00516.17
7.0.140.0050.03818.18
7.0.130.0030.00716.22
7.0.120.0060.00816.08
7.0.110.0050.00816.28
7.0.100.0120.03417.46
7.0.90.0090.02717.39
7.0.80.0100.03217.34
7.0.70.0100.02817.49
7.0.60.0170.03417.47
7.0.50.0110.02917.61
7.0.40.0110.03216.11
7.0.30.0080.03116.22
7.0.20.0060.03316.17
7.0.10.0030.02516.20
7.0.00.0100.03116.15
5.6.400.0110.00615.52
5.6.390.0080.00615.09
5.6.380.0060.01315.33
5.6.370.0100.00315.33
5.6.360.0050.00915.37
5.6.350.0050.00915.21
5.6.340.0080.00815.47
5.6.330.0030.01115.30
5.6.320.0110.00815.37
5.6.310.0050.01215.40
5.6.300.0050.01115.38
5.6.290.0080.00815.27
5.6.280.0020.03217.23
5.6.270.0070.00915.31
5.6.260.0100.00615.22
5.6.250.0060.03217.16
5.6.240.0070.02717.09
5.6.230.0080.03216.97
5.6.220.0110.03117.12
5.6.210.0100.03017.06
5.6.200.0080.03117.22
5.6.190.0060.03817.15
5.6.180.0060.03617.16
5.6.170.0120.02917.14
5.6.160.0080.02217.14
5.6.150.0100.03417.24
5.6.140.0080.03517.23
5.6.130.0070.03817.21
5.6.120.0100.03117.17
5.6.110.0100.03017.13
5.6.100.0110.03017.29
5.6.90.0060.03017.18
5.6.80.0060.03116.89
5.6.70.0110.02316.95
5.6.60.0070.03016.88
5.6.50.0070.03416.98
5.6.40.0080.03416.85
5.6.30.0030.03616.88
5.6.20.0070.03316.88
5.6.10.0080.03116.89
5.6.00.0110.02816.87
5.5.380.0090.03116.80
5.5.370.0090.03016.93
5.5.360.0120.03416.85
5.5.350.0070.03216.99
5.5.340.0110.02917.09
5.5.330.0090.03317.12
5.5.320.0080.03017.10
5.5.310.0110.02917.00
5.5.300.0080.03517.03
5.5.290.0070.03116.97
5.5.280.0080.03117.13
5.5.270.0080.02617.11
5.5.260.0050.02617.09
5.5.250.0050.02416.97
5.5.240.0060.03216.82
5.5.230.0100.02016.91
5.5.220.0100.03016.86
5.5.210.0070.02816.78
5.5.200.0070.03316.70
5.5.190.0050.03216.71
5.5.180.0050.03716.88
5.5.170.0020.01115.04
5.5.160.0100.03016.84
5.5.150.0110.02516.90
5.5.140.0050.02316.83
5.5.130.0100.02816.64
5.5.120.0040.03216.71
5.5.110.0070.02716.75
5.5.100.0070.03516.69
5.5.90.0110.02216.78
5.5.80.0100.02816.70
5.5.70.0020.03416.79
5.5.60.0090.03016.86
5.5.50.0090.03216.76
5.5.40.0120.02716.67
5.5.30.0070.03016.85
5.5.20.0070.01816.63
5.5.10.0100.02616.64
5.5.00.0060.03016.74
5.4.450.0080.03114.35
5.4.440.0050.03014.40
5.4.430.0080.03114.36
5.4.420.0090.02614.26
5.4.410.0090.02714.37
5.4.400.0040.03414.33
5.4.390.0080.02514.39
5.4.380.0030.02614.23
5.4.370.0050.03014.22
5.4.360.0030.03114.24
5.4.350.0030.02814.23
5.4.340.0070.02714.38
5.4.330.0040.00411.93
5.4.320.0060.02914.24
5.4.310.0060.03114.17
5.4.300.0040.01914.21
5.4.290.0070.02614.26
5.4.280.0110.02714.39
5.4.270.0070.02914.34
5.4.260.0040.03014.33
5.4.250.0060.03014.21
5.4.240.0110.02614.24
5.4.230.0040.03014.10
5.4.220.0050.03214.28
5.4.210.0070.02814.32
5.4.200.0090.01614.21
5.4.190.0070.02914.20
5.4.180.0030.02514.21
5.4.170.0040.02914.16
5.4.160.0050.03014.16
5.4.150.0030.02414.23
5.4.140.0050.03013.40
5.4.130.0030.02813.24
5.4.120.0050.01613.38
5.4.110.0030.01813.40
5.4.100.0060.01613.41
5.4.90.0070.01613.44
5.4.80.0040.01813.47
5.4.70.0010.02013.46
5.4.60.0040.01613.35
5.4.50.0050.01713.44
5.4.40.0050.01613.35
5.4.30.0060.01513.51
5.4.20.0060.01613.28
5.4.10.0030.02813.40
5.4.00.0060.02313.26
5.3.290.0050.02712.67
5.3.280.0060.02912.61
5.3.270.0060.03012.54
5.3.260.0040.03012.64
5.3.250.0040.02912.65
5.3.240.0050.02112.66
5.3.230.0040.02012.56
5.3.220.0030.01812.60
5.3.210.0060.01512.64
5.3.200.0040.01912.60
5.3.190.0040.01812.53
5.3.180.0060.01612.68
5.3.170.0080.01312.63
5.3.160.0080.01212.71
5.3.150.0080.01412.59
5.3.140.0040.01612.56
5.3.130.0060.01312.66
5.3.120.0070.01312.69
5.3.110.0060.01812.56
5.3.100.0030.02312.47
5.3.90.0080.01912.44
5.3.80.0020.02512.43
5.3.70.0030.01812.43
5.3.60.0030.01712.37
5.3.50.0050.02612.46
5.3.40.0020.02712.43
5.3.30.0010.01612.27
5.3.20.0020.01812.28
5.3.10.0020.01612.25
5.3.00.0040.01412.19
5.2.170.0000.03011.16
5.2.160.0030.02711.27
5.2.150.0100.02311.21
5.2.140.0100.02311.24
5.2.130.0030.02711.03
5.2.120.0000.03011.19
5.2.110.0000.03311.09
5.2.100.0000.03311.02
5.2.90.0030.02711.00
5.2.80.0030.03011.14
5.2.70.0030.02710.96
5.2.60.0070.02711.08
5.2.50.0000.03011.09
5.2.40.0000.03010.87
5.2.30.0000.03011.00
5.2.20.0030.02710.92
5.2.10.0030.02710.91
5.2.00.0000.03310.67
5.1.60.0030.02310.10
5.1.50.0030.02310.09
5.1.40.0030.0239.87
5.1.30.0100.01710.26
5.1.20.0030.02310.49
5.1.10.0030.03010.19
5.1.00.0030.02710.10
5.0.50.0000.0239.78
5.0.40.0030.0179.78
5.0.30.0000.0309.78
5.0.20.0000.0239.78
5.0.10.0000.0279.78
5.0.00.0000.0339.78
4.4.90.0030.0139.78
4.4.80.0000.0179.78
4.4.70.0000.0179.78
4.4.60.0000.0209.78
4.4.50.0030.0139.78
4.4.40.0000.0279.78
4.4.30.0000.0179.78
4.4.20.0000.0239.78
4.4.10.0030.0139.78
4.4.00.0000.0309.78
4.3.110.0000.0139.78
4.3.100.0030.0139.78
4.3.90.0030.0139.78
4.3.80.0000.0239.78
4.3.70.0030.0139.78
4.3.60.0000.0179.78
4.3.50.0030.0139.78
4.3.40.0000.0239.78
4.3.30.0000.0179.78
4.3.20.0000.0179.78
4.3.10.0030.0109.78
4.3.00.0000.0139.78

preferences:
89.23 ms | 401 KiB | 5 Q