3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* span :: (a -> Bool) -> [a] -> ([a],[a]) span _ xs@[] = (xs, xs) span p xs@(x:xs') | p x = let (ys,zs) = span p xs' in (x:ys,zs) | otherwise = ([],xs) */ function span($p, $xs) { if (empty($xs)) { return [[], []]; } $xs_ = $xs; $x = array_shift($xs_); if ($p($x)) { list($ys, $zs) = span($p, $xs_); return [array_merge([$x], $ys), $zs]; } return [[], $xs]; } /* groupBy :: (a -> a -> Bool) -> [a] -> [[a]] groupBy _ [] = [] groupBy eq (x:xs) = (x:ys) : groupBy eq zs where (ys,zs) = span (eq x) xs */ function array_group(callable $eq, array $xs) { if (empty($xs)) { return []; } $x = array_shift($xs); // curry of $eq $eqx = function ($y) use ($eq, $x) { return $eq($x, $y); }; list($ys, $zs) = span($eqx, $xs); return array_merge([array_merge([$x], $ys)], array_group($eq, $zs)); } function it($m,$p){echo ($p?'OK':'NO')." It $m\n"; if(!$p){$GLOBALS['f']=1;}} print_r(array_group(function ($a, $b) { return ($a == ($b-1)) || ($a==$b); }, [1, 1, 2, 1]));

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.0150.00018.63
8.3.30.0120.00319.04
8.3.20.0080.00020.29
8.3.10.0000.00823.64
8.3.00.0090.00019.25
8.2.170.0090.01222.96
8.2.160.0000.01420.34
8.2.150.0150.00024.18
8.2.140.0060.00324.66
8.2.130.0070.00026.16
8.2.120.0070.00022.16
8.2.110.0060.00320.57
8.2.100.0120.00018.16
8.2.90.0040.00419.36
8.2.80.0040.00417.97
8.2.70.0040.00417.50
8.2.60.0000.00817.93
8.2.50.0040.00418.07
8.2.40.0060.00320.07
8.2.30.0050.00218.22
8.2.20.0070.00017.83
8.2.10.0020.00518.13
8.2.00.0070.00017.70
8.1.270.0060.00322.19
8.1.260.0030.00526.35
8.1.250.0000.01228.09
8.1.240.0040.00423.68
8.1.230.0040.00719.00
8.1.220.0030.00617.76
8.1.210.0000.00918.77
8.1.200.0030.00717.23
8.1.190.0050.00317.23
8.1.180.0030.00618.10
8.1.170.0080.00018.42
8.1.160.0040.00422.00
8.1.150.0000.00718.90
8.1.140.0000.00717.52
8.1.130.0000.00717.84
8.1.120.0070.00017.48
8.1.110.0080.00017.44
8.1.100.0000.00717.52
8.1.90.0030.00517.45
8.1.80.0000.00717.30
8.1.70.0030.00517.36
8.1.60.0040.00417.59
8.1.50.0030.00517.51
8.1.40.0070.00017.54
8.1.30.0040.00417.53
8.1.20.0030.00517.67
8.1.10.0030.00517.60
8.1.00.0000.00817.45
8.0.300.0080.00018.77
8.0.290.0040.00416.75
8.0.280.0070.00018.53
8.0.270.0070.00017.16
8.0.260.0000.00617.19
8.0.250.0100.00017.11
8.0.240.0040.00417.12
8.0.230.0000.00717.05
8.0.220.0030.00317.05
8.0.210.0000.00816.94
8.0.200.0000.00717.04
8.0.190.0070.00016.94
8.0.180.0070.00017.05
8.0.170.0080.00016.98
8.0.160.0000.00717.03
8.0.150.0070.00016.82
8.0.140.0040.00416.90
8.0.130.0000.00613.45
8.0.120.0040.00416.83
8.0.110.0050.00216.83
8.0.100.0070.00016.98
8.0.90.0000.00816.84
8.0.80.0160.00616.98
8.0.70.0040.00416.93
8.0.60.0000.00716.77
8.0.50.0050.00216.92
8.0.30.0110.01317.39
8.0.20.0090.01417.40
8.0.10.0040.00417.05
8.0.00.0080.00916.78
7.4.330.0000.00615.10
7.4.320.0030.00616.52
7.4.300.0000.00616.63
7.4.290.0000.00716.64
7.4.280.0030.00316.61
7.4.270.0070.00016.56
7.4.260.0030.00316.66
7.4.250.0030.00316.48
7.4.240.0020.00516.59
7.4.230.0000.00716.44
7.4.220.0140.00316.52
7.4.210.0030.01816.46
7.4.200.0070.00016.70
7.4.160.0130.00316.75
7.4.150.0160.00317.40
7.4.140.0130.00717.86
7.4.130.0080.00816.60
7.4.120.0100.00616.47
7.4.110.0100.00716.59
7.4.100.0120.00416.73
7.4.90.0070.01016.55
7.4.80.0110.00719.39
7.4.70.0030.01416.52
7.4.60.0030.01316.41
7.4.50.0000.00516.57
7.4.40.0120.00416.27
7.4.30.0080.00816.59
7.4.00.0110.00615.08
7.3.330.0000.00613.35
7.3.320.0050.00013.36
7.3.310.0030.00516.38
7.3.300.0000.00716.35
7.3.290.0120.00616.38
7.3.280.0120.00916.37
7.3.270.0120.00617.40
7.3.260.0140.00516.64
7.3.250.0080.00916.52
7.3.240.0110.00816.52
7.3.230.0070.01016.58
7.3.210.0120.00616.56
7.3.200.0090.01219.39
7.3.190.0110.00616.45
7.3.180.0080.00816.42
7.3.170.0190.00316.81
7.3.160.0100.00716.71
7.2.330.0120.00916.72
7.2.320.0090.00916.54
7.2.310.0030.01416.74
7.2.300.0070.01016.68
7.2.290.0080.01216.86
7.2.60.0040.01117.02
7.2.00.0040.01119.36
7.1.200.0000.01115.93
7.1.100.0030.01018.33
7.1.70.0000.00817.17
7.1.60.0120.01219.11
7.1.50.0060.01616.68
7.1.00.0000.08022.36
7.0.200.0040.00416.65
7.0.140.0070.07021.93
7.0.60.0100.08319.84
7.0.50.0170.06017.91
7.0.40.0130.08320.04
7.0.30.0230.04320.06
7.0.20.0270.04320.30
7.0.10.0100.04720.22
7.0.00.0070.06020.18
5.6.280.0070.07020.93
5.6.210.0000.04320.75
5.6.200.0130.07318.26
5.6.190.0070.07020.60
5.6.180.0230.07320.55
5.6.170.0200.03720.48
5.6.160.0030.08320.43
5.6.150.0070.06718.14
5.6.140.0030.03718.24
5.6.130.0070.08018.14
5.6.120.0000.04320.98
5.6.110.0070.08320.92
5.6.100.0130.04720.99
5.6.90.0130.07721.06
5.6.80.0230.04720.54
5.6.70.4070.03720.44
5.5.350.0100.08720.35
5.5.340.0030.05317.99
5.5.330.0070.06720.21
5.5.320.0330.05020.28
5.5.310.0230.08320.34
5.5.300.0030.05317.95
5.5.290.0100.05017.94
5.5.280.0130.07720.98
5.5.270.0170.07320.86
5.5.260.0030.04320.66
5.5.250.0170.05320.70
5.5.240.0330.07020.28
5.4.450.0830.05719.63
5.4.440.0770.06019.48
5.4.430.1000.06719.38
5.4.420.0800.04719.38
5.4.410.0870.06719.47
5.4.400.0930.05718.88
5.4.390.0730.05319.01
5.4.380.0830.06718.98
5.4.370.0830.05318.84
5.4.360.0570.06318.84
5.4.350.1000.05718.86
5.4.340.0070.04012.03
5.4.320.0060.04212.52
5.4.310.0070.04712.52
5.4.300.0050.04412.52
5.4.290.0080.04612.52
5.4.280.0060.04212.41
5.4.270.0050.03812.41
5.4.260.0040.04112.41
5.4.250.0060.04712.41
5.4.240.0070.04312.41
5.4.230.0090.04912.41
5.4.220.0090.04012.41
5.4.210.0070.03812.41
5.4.200.0060.04412.41
5.4.190.0090.04112.40
5.4.180.0090.03512.41
5.4.170.0090.03312.41
5.4.160.0090.04112.41
5.4.150.0070.04512.40
5.4.140.0040.04112.08
5.4.130.0130.04012.07
5.4.120.0080.04812.04
5.4.110.0130.04312.03
5.4.100.0070.04112.03
5.4.90.0100.04312.03
5.4.80.0120.03612.03
5.4.70.0050.03912.02
5.4.60.0070.03612.02
5.4.50.0050.03912.02
5.4.40.0060.03612.01
5.4.30.0070.03612.01
5.4.20.0040.04112.01
5.4.10.0110.03912.00
5.4.00.0070.05211.50
5.3.290.0090.05412.80
5.3.280.0120.04512.71
5.3.270.0080.05512.73
5.3.260.0060.04312.72
5.3.250.0020.04312.72
5.3.240.0100.03712.72
5.3.230.0090.04912.71
5.3.220.0100.04912.68
5.3.210.0060.05612.68
5.3.200.0080.04512.68
5.3.190.0070.03712.68
5.3.180.0070.03712.67
5.3.170.0080.03512.67
5.3.160.0050.03912.67
5.3.150.0070.03812.68
5.3.140.0080.03712.66
5.3.130.0100.04812.66
5.3.120.0050.04712.66
5.3.110.0060.04212.66
5.3.100.0090.03612.13
5.3.90.0090.04412.11
5.3.80.0090.03412.09
5.3.70.0070.03812.09
5.3.60.0080.03412.08
5.3.50.0060.03612.02
5.3.40.0060.03612.02
5.3.30.0050.03611.98
5.3.20.0050.03711.77
5.3.10.0070.03511.73
5.3.00.0070.03611.71
5.2.170.0060.0309.21
5.2.160.0070.0279.21
5.2.150.0060.0309.21
5.2.140.0050.0319.21
5.2.130.0050.0299.17
5.2.120.0050.0299.17
5.2.110.0060.0289.18
5.2.100.0050.0289.18
5.2.90.0090.0259.17
5.2.80.0040.0339.17
5.2.70.0040.0329.18
5.2.60.0060.0329.13
5.2.50.0070.0409.09
5.2.40.0070.0369.07
5.2.30.0060.0339.05
5.2.20.0070.0309.04
5.2.10.0030.0338.95
5.2.00.0090.0258.81
5.1.60.0060.0218.09
5.1.50.0030.0258.09
5.1.40.0020.0268.07
5.1.30.0050.0258.42
5.1.20.0060.0248.44
5.1.10.0040.0268.16
5.1.00.0050.0258.17
5.0.50.0020.0226.64
5.0.40.0050.0186.50
5.0.30.0020.0426.31
5.0.20.0040.0256.28
5.0.10.0050.0266.26
5.0.00.0030.0396.25
4.4.90.0040.0214.78
4.4.80.0060.0184.76
4.4.70.0060.0184.75
4.4.60.0010.0224.75
4.4.50.0040.0214.77
4.4.40.0030.0324.71
4.4.30.0040.0184.76
4.4.20.0030.0214.84
4.4.10.0040.0214.85
4.4.00.0040.0314.76
4.3.110.0030.0224.67
4.3.100.0040.0214.67
4.3.90.0080.0174.64
4.3.80.0040.0294.58
4.3.70.0060.0134.63
4.3.60.0090.0134.63
4.3.50.0050.0164.63
4.3.40.0020.0314.53
4.3.30.0020.0173.30
4.3.20.0010.0173.28
4.3.10.0020.0163.24
4.3.00.0200.0206.66

preferences:
42.37 ms | 400 KiB | 5 Q