3v4l.org

run code in 300+ PHP versions simultaneously
<?php function chain($iterable, array $functions) { foreach ($functions as $function) { $iterable = $function(as_iterator($iterable)); } } function as_iterator($iterable) { if ($iterable instanceof \Iterator) { return $iterable; } if (is_array($iterable)) { return new \ArrayIterator($iterable); } if (is_string($iterable)) { return new \ArrayIterator(str_split($iterable)); } throw new \Exception(); } function do_map(callable $function) { return function(Iterator $iterator) use ($function) { foreach ($iterator as $key => $value) { yield $key => $value; } }; } function do_filter(callable $function) { return function(Iterator $iterator) use($function) { foreach ($iterator as $key => $value) { if ($function($value, $key)) { yield $key => $value; } } }; } function do_concat($iterable) { return function(Iterator $iterator) use ($iterable) { foreach ($iterator as $value) { yield $value; } foreach (as_iterator($iterable) as $value) { yield $value; } }; } function do_as_array() { return function(Iterator $iterator) { return iterator_to_array($iterator); }; } $array = chain([1, 2, 3, 4], [ do_concat([5, 6, 7, 8]), do_filter(function ($v) { return $v % 2 == 0; }), do_map(function ($v) { return $v * 3; }), do_as_array(), ]);

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.0110.00418.14
8.3.50.0110.00821.08
8.3.40.0150.00318.80
8.3.30.0140.00319.04
8.3.20.0070.00020.35
8.3.10.0050.00323.51
8.3.00.0080.00019.38
8.2.180.0060.00916.75
8.2.170.0130.00322.96
8.2.160.0100.00720.53
8.2.150.0080.00024.18
8.2.140.0090.00024.66
8.2.130.0000.00726.16
8.2.120.0040.00422.24
8.2.110.0040.00420.45
8.2.100.0080.00318.09
8.2.90.0040.00419.13
8.2.80.0030.00617.97
8.2.70.0060.00317.63
8.2.60.0030.00617.67
8.2.50.0090.00018.07
8.2.40.0030.00620.01
8.2.30.0040.00417.98
8.2.20.0030.00617.65
8.2.10.0060.00318.00
8.2.00.0000.00717.71
8.1.280.0000.01425.92
8.1.270.0070.01122.22
8.1.260.0000.00726.35
8.1.250.0050.00328.09
8.1.240.0060.00323.83
8.1.230.0110.00019.00
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0030.00617.23
8.1.190.0040.00417.38
8.1.180.0040.00418.10
8.1.170.0000.00818.54
8.1.160.0030.00621.93
8.1.150.0070.00018.82
8.1.140.0040.00417.41
8.1.130.0040.00417.86
8.1.120.0040.00417.42
8.1.110.0040.00417.37
8.1.100.0040.00417.47
8.1.90.0050.00217.45
8.1.80.0050.00317.53
8.1.70.0000.00717.44
8.1.60.0030.00617.63
8.1.50.0000.00817.48
8.1.40.0000.00817.45
8.1.30.0040.00417.68
8.1.20.0030.00617.54
8.1.10.0030.00517.67
8.1.00.0000.00917.60
8.0.300.0040.00418.77
8.0.290.0040.00416.75
8.0.280.0000.00818.40
8.0.270.0070.00017.21
8.0.260.0000.00817.33
8.0.250.0000.00716.91
8.0.240.0050.00316.95
8.0.230.0000.00717.04
8.0.220.0030.00317.00
8.0.210.0030.00317.00
8.0.200.0030.00317.01
8.0.190.0050.00217.04
8.0.180.0040.00416.90
8.0.170.0080.00016.86
8.0.160.0070.00016.96
8.0.150.0000.00816.84
8.0.140.0050.00316.91
8.0.130.0030.00313.46
8.0.120.0040.00416.98
8.0.110.0000.00717.03
8.0.100.0040.00416.97
8.0.90.0050.00317.01
8.0.80.0070.01416.95
8.0.70.0000.00716.87
8.0.60.0040.00416.93
8.0.50.0040.00416.90
8.0.30.0110.00817.25
8.0.20.0070.01217.46
8.0.10.0050.00317.11
8.0.00.0110.01016.78
7.4.330.0030.00315.02
7.4.320.0030.00316.64
7.4.300.0000.00716.54
7.4.290.0080.00016.55
7.4.280.0100.00016.63
7.4.270.0030.00316.65
7.4.260.0040.00416.59
7.4.250.0030.00716.57
7.4.240.0020.00516.55
7.4.230.0040.00416.54
7.4.220.0090.01516.49
7.4.210.0090.01216.71
7.4.200.0070.00016.38
7.4.160.0060.01016.57
7.4.150.0100.00917.40
7.4.140.0090.01117.86
7.4.130.0110.00516.62
7.4.120.0070.01116.47
7.4.110.0070.01016.67
7.4.100.0030.01416.64
7.4.90.0100.00616.53
7.4.80.0060.01319.39
7.4.70.0070.01016.56
7.4.60.0060.00916.62
7.4.50.0030.00616.35
7.4.40.0070.01016.52
7.4.30.0040.01216.32
7.4.10.0060.00915.24
7.4.00.0040.01415.01
7.3.330.0030.00313.25
7.3.320.0000.00613.27
7.3.310.0040.00416.42
7.3.300.0050.00216.37
7.3.290.0100.00616.38
7.3.280.0110.00616.38
7.3.270.0070.01117.40
7.3.260.0080.00816.65
7.3.250.0060.01416.58
7.3.240.0120.00616.48
7.3.230.0140.00816.64
7.3.210.0080.00816.37
7.3.200.0160.00719.39
7.3.190.0110.00716.34
7.3.180.0060.01216.70
7.3.170.0110.00616.66
7.3.160.0060.01116.70
7.3.130.0000.01815.04
7.3.120.0050.01314.90
7.3.110.0100.00614.72
7.3.100.0090.00514.95
7.3.90.0060.01214.98
7.3.80.0070.00514.89
7.3.70.0030.00714.81
7.3.60.0060.00714.86
7.3.50.0060.00614.86
7.3.40.0050.00414.88
7.3.30.0080.00315.01
7.3.20.0090.00516.65
7.3.10.0050.00916.81
7.3.00.0050.01016.48
7.2.330.0030.01416.89
7.2.320.0150.00616.82
7.2.310.0090.01216.58
7.2.300.0100.00716.79
7.2.290.0090.01216.50
7.2.260.0140.00415.18
7.2.250.0130.00715.33
7.2.240.0120.00515.07
7.2.230.0080.00915.22
7.2.220.0070.00915.01
7.2.210.0050.01115.20
7.2.200.0050.00715.12
7.2.190.0070.00815.08
7.2.180.0020.01315.10
7.2.170.0070.00715.04
7.2.160.0060.00614.94
7.2.150.0000.01217.10
7.2.140.0000.01417.00
7.2.130.0040.00816.96
7.2.120.0050.00516.78
7.2.110.0100.01016.80
7.2.100.0140.00716.85
7.2.90.0060.00917.05
7.2.80.0060.00716.91
7.2.70.0100.00616.73
7.2.60.0120.00816.90
7.2.50.0070.01016.95
7.2.40.0060.00916.98
7.2.30.0070.01016.84
7.2.20.0000.01617.02
7.2.10.0030.01316.94
7.2.00.0060.00618.13
7.1.330.0070.00915.99
7.1.320.0070.01015.72
7.1.310.0050.00715.80
7.1.300.0070.00915.76
7.1.290.0060.00915.74
7.1.280.0030.00715.96
7.1.270.0050.00615.53
7.1.260.0030.00815.86
7.1.250.0040.00415.84
7.1.240.0090.00315.68
7.1.230.0030.00615.88
7.1.220.0050.00515.77
7.1.210.0040.01116.01
7.1.200.0040.00415.77
7.1.190.0040.01415.68
7.1.180.0030.01615.54
7.1.170.0040.01115.91
7.1.160.0070.00715.98
7.1.150.0090.00015.97
7.1.140.0040.00815.77
7.1.130.0090.00615.71
7.1.120.0070.00715.73
7.1.110.0070.00615.98
7.1.100.0020.01216.96
7.1.90.0030.00915.87
7.1.80.0000.01116.04
7.1.70.0080.00416.48
7.1.60.0090.01117.42
7.1.50.0070.00916.33
7.1.40.0090.00615.86
7.1.30.0100.00715.82
7.1.20.0080.00615.90
7.1.10.0030.00615.95
7.1.00.0050.04019.10
7.0.330.0110.00415.39
7.0.320.0030.00715.45
7.0.310.0070.00715.45
7.0.300.0070.00715.28
7.0.290.0030.01315.62
7.0.280.0060.00615.32
7.0.270.0060.00915.29
7.0.260.0100.00315.36
7.0.250.0030.01215.43
7.0.240.0000.00915.42
7.0.230.0060.01115.39
7.0.220.0030.00915.43
7.0.210.0030.01215.57
7.0.200.0060.00416.23
7.0.190.0040.00815.36
7.0.180.0060.00915.21
7.0.170.0070.00715.47
7.0.160.0070.00715.51
7.0.150.0000.00915.54
7.0.140.0020.03918.65
7.0.130.0030.01415.56
7.0.120.0060.01015.32
7.0.110.0040.01115.54
7.0.100.0060.00915.29
7.0.90.0040.01115.20
7.0.80.0030.01015.45
7.0.70.0080.00815.63
7.0.60.0020.03517.62
7.0.50.0020.03216.82
7.0.40.0050.04616.90
7.0.30.0080.02616.81
7.0.20.0130.02516.97
7.0.10.0090.04516.82
7.0.00.0030.02816.78
5.6.400.0060.00814.20
5.6.390.0060.00314.30
5.6.380.0000.00914.30
5.6.370.0090.01214.62
5.6.360.0150.00014.21
5.6.350.0100.00314.65
5.6.340.0080.00514.21
5.6.330.0030.00914.11
5.6.320.0070.00714.17
5.6.310.0090.00614.57
5.6.300.0030.01014.28
5.6.290.0130.00314.13
5.6.280.0070.04017.69
5.6.270.0100.00314.28
5.6.260.0030.01014.24
5.6.250.0070.00714.65
5.6.240.0070.00714.36
5.6.230.0100.01014.50
5.6.220.0030.01014.32
5.6.210.0070.03217.60
5.6.200.0050.03216.39
5.6.190.0090.03017.54
5.6.180.0150.04517.46
5.6.170.0150.04417.41
5.6.160.0070.04017.50
5.6.150.0060.03316.34
5.6.140.0050.02516.30
5.6.130.0050.04116.40
5.6.120.0050.02417.76
5.6.110.0030.03617.65
5.6.100.0070.04517.83
5.6.90.0080.04517.59
5.6.80.0040.04517.51
5.6.70.0100.00314.24
5.6.60.0000.01114.02
5.6.50.0090.00314.32
5.6.40.0140.00014.55
5.6.30.0000.01414.30
5.6.20.0070.00714.31
5.6.10.0000.01314.42
5.6.00.0040.00714.34
5.5.380.0130.00314.03
5.5.370.0030.01314.47
5.5.360.0060.00614.17
5.5.350.0080.04217.33
5.5.340.0030.04816.09
5.5.330.0020.05017.31
5.5.320.0120.04717.32
5.5.310.0140.04317.15
5.5.300.0050.04616.21
5.5.290.0050.02316.21
5.5.280.0050.02517.75
5.5.270.0050.04117.54
5.5.260.0050.03717.52
5.5.250.0060.04417.56
5.5.240.0080.02317.16
5.5.230.0070.00314.23
5.5.220.0070.00314.27
5.5.210.0100.00314.11
5.5.200.0060.00314.30
5.5.190.0030.01014.13
5.5.180.0000.01714.18
5.5.170.0070.00714.07
5.5.160.0050.00514.30
5.5.150.0060.00614.32
5.5.140.0030.00714.33
5.5.130.0030.00814.41
5.5.120.0030.00714.16
5.5.110.0060.00614.11
5.5.100.0060.00614.23
5.5.90.0030.00614.41
5.5.80.0070.00314.29
5.5.70.0060.00614.02
5.5.60.0000.01214.07
5.5.50.0030.00713.99
5.5.40.0110.00314.14
5.5.30.0030.01014.11
5.5.20.0060.00314.26
5.5.10.0000.01714.05
5.5.00.0030.01014.45
5.4.450.0130.02615.07
5.4.440.0130.02715.19
5.4.430.0130.02715.13
5.4.420.0160.03915.28
5.4.410.0170.02314.98
5.4.400.0150.03714.99
5.4.390.0150.03214.99
5.4.380.0110.02014.83
5.4.370.0170.02914.95
5.4.360.0120.04214.85
5.4.350.0130.02715.10
5.4.340.0100.04114.80
5.4.330.0030.00610.85
5.4.320.0190.03615.04
5.4.310.0130.04015.06
5.4.300.0150.04014.87
5.4.290.0150.02715.04
5.4.280.0140.04114.80
5.4.270.0130.03714.89
5.4.260.0100.02415.04
5.4.250.0130.03314.84
5.4.240.0120.03014.77
5.4.230.0090.02314.88
5.4.220.0130.02415.07
5.4.210.0140.02814.90
5.4.200.0100.03414.71
5.4.190.0120.03914.72
5.4.180.0100.02714.87
5.4.170.0120.02014.88
5.4.160.0130.03714.91
5.4.150.0200.03515.11
5.4.140.0170.03813.65
5.4.130.0100.04013.71
5.4.120.0150.02313.53
5.4.110.0230.01813.74
5.4.100.0110.02613.70
5.4.90.0130.03213.58
5.4.80.0170.03713.68
5.4.70.0110.03913.57
5.4.60.0100.03913.70
5.4.50.0150.02713.65
5.4.40.0130.03713.54
5.4.30.0130.03813.45
5.4.20.0130.03513.64
5.4.10.0110.04313.70
5.4.00.0100.03613.33
5.3.290.0170.06714.84
5.3.280.0170.03714.58
5.3.270.0200.05714.61
5.3.260.0300.04014.59
5.3.250.0200.07714.75
5.3.240.0200.06714.67
5.3.230.0170.04314.61
5.3.220.0230.07014.74
5.3.210.0170.04014.50
5.3.200.0300.06314.63
5.3.190.0270.04314.74
5.3.180.0270.06714.69
5.3.170.0230.06714.65
5.3.160.0100.04314.60
5.3.150.0130.07014.55
5.3.140.0200.06014.55
5.3.130.0230.07314.47
5.3.120.0270.06314.43
5.3.110.0330.04714.58
5.3.100.0200.07714.05
5.3.90.0230.07014.04
5.3.80.0300.06314.20
5.3.70.0200.08014.12
5.3.60.0130.05714.10
5.3.50.0270.05313.94
5.3.40.0170.04013.93
5.3.30.0130.04013.94
5.3.20.0200.05313.79
5.3.10.0330.05313.79
5.3.00.0200.05713.88
5.2.170.0100.03312.12
5.2.160.0100.03712.12
5.2.150.0130.03712.12
5.2.140.0200.02712.12
5.2.130.0170.06012.12
5.2.120.0170.04012.12
5.2.110.0200.05312.12
5.2.100.0100.03312.12
5.2.90.0300.04712.12
5.2.80.0230.04712.12
5.2.70.0170.05012.12
5.2.60.0200.04712.12
5.2.50.0230.05712.12
5.2.40.0100.04712.12
5.2.30.0170.05012.12
5.2.20.0130.06012.12
5.2.10.0170.05712.12
5.2.00.0070.04712.12
5.1.60.0200.04712.12
5.1.50.0200.04712.12
5.1.40.0200.05012.12
5.1.30.0230.04712.12
5.1.20.0100.03012.12
5.1.10.0200.02712.12
5.1.00.0230.03012.12
5.0.50.0100.04012.12
5.0.40.0070.04712.12
5.0.30.0070.03712.12
5.0.20.0070.02012.12
5.0.10.0130.04012.12
5.0.00.0070.04312.12
4.4.90.0070.01712.12
4.4.80.0070.02012.12
4.4.70.0070.03312.12
4.4.60.0100.02712.12
4.4.50.0170.02712.12
4.4.40.0100.05012.12
4.4.30.0070.03712.12
4.4.20.0130.02712.12
4.4.10.0070.03012.12
4.4.00.0100.03312.12
4.3.110.0170.02712.12
4.3.100.0100.01312.12
4.3.90.0070.01712.12
4.3.80.0070.02712.12
4.3.70.0170.02712.12
4.3.60.0100.02012.12
4.3.50.0100.02312.12
4.3.40.0070.03012.12
4.3.30.0030.01712.12
4.3.20.0100.01012.12
4.3.10.0000.01712.12
4.3.00.0070.01312.12

preferences:
40.33 ms | 401 KiB | 5 Q