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, 3, 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.0060.00918.89
8.3.30.0100.00319.17
8.3.20.0030.00520.16
8.3.10.0040.00423.71
8.3.00.0030.00519.25
8.2.170.0030.01022.96
8.2.160.0140.00020.22
8.2.150.0120.00324.18
8.2.140.0000.00824.66
8.2.130.0070.00026.16
8.2.120.0050.00322.09
8.2.110.0000.00920.35
8.2.100.0090.00318.03
8.2.90.0050.00319.26
8.2.80.0000.00817.97
8.2.70.0100.00017.63
8.2.60.0050.00317.93
8.2.50.0080.00018.07
8.2.40.0030.00619.95
8.2.30.0050.00318.02
8.2.20.0040.00417.70
8.2.10.0000.00718.07
8.2.00.0000.00817.77
8.1.270.0090.00022.02
8.1.260.0050.00226.35
8.1.250.0080.00028.09
8.1.240.0040.00423.80
8.1.230.0040.00818.97
8.1.220.0030.00617.79
8.1.210.0040.00418.77
8.1.200.0000.01117.35
8.1.190.0040.00417.22
8.1.180.0000.00818.10
8.1.170.0040.00418.59
8.1.160.0030.00322.03
8.1.150.0000.00718.90
8.1.140.0040.00417.42
8.1.130.0050.00317.90
8.1.120.0000.00717.45
8.1.110.0000.00717.48
8.1.100.0070.00017.36
8.1.90.0000.00717.51
8.1.80.0030.00517.52
8.1.70.0030.00317.42
8.1.60.0030.00617.59
8.1.50.0000.00817.61
8.1.40.0050.00317.48
8.1.30.0030.00517.71
8.1.20.0000.00817.70
8.1.10.0030.00517.55
8.1.00.0070.00017.56
8.0.300.0050.00318.77
8.0.290.0000.00716.63
8.0.280.0030.00318.46
8.0.270.0030.00317.33
8.0.260.0030.00317.29
8.0.250.0040.00317.01
8.0.240.0040.00416.92
8.0.230.0030.00317.07
8.0.220.0080.00016.88
8.0.210.0050.00216.99
8.0.200.0030.00317.04
8.0.190.0000.00717.00
8.0.180.0030.00516.97
8.0.170.0050.00216.90
8.0.160.0040.00417.10
8.0.150.0030.00316.79
8.0.140.0040.00416.95
8.0.130.0030.00313.39
8.0.120.0030.00616.85
8.0.110.0030.00517.00
8.0.100.0000.00716.79
8.0.90.0050.00216.95
8.0.80.0090.00916.96
8.0.70.0040.00417.05
8.0.60.0070.00016.80
8.0.50.0000.00716.98
8.0.30.0130.00917.11
8.0.20.0080.01017.40
8.0.10.0000.00717.21
8.0.00.0080.01016.78
7.4.330.0030.00315.02
7.4.320.0080.00016.46
7.4.300.0060.00016.68
7.4.290.0060.00016.62
7.4.280.0030.00316.46
7.4.270.0070.00016.64
7.4.260.0030.00316.51
7.4.250.0040.00416.47
7.4.240.0020.00516.55
7.4.230.0040.00416.68
7.4.220.0110.01116.66
7.4.210.0170.00316.74
7.4.200.0000.00716.70
7.4.160.0100.00716.43
7.4.150.0190.00017.40
7.4.140.0060.01117.86
7.4.130.0110.00616.53
7.4.120.0070.01116.52
7.4.110.0030.01316.29
7.4.100.0100.00616.42
7.4.90.0140.00316.41
7.4.80.0040.01419.39
7.4.70.0100.00916.63
7.4.60.0060.01016.41
7.4.50.0030.00316.37
7.4.40.0130.00316.37
7.4.30.0090.00616.42
7.4.00.0030.01214.92
7.3.330.0050.00013.36
7.3.320.0000.00513.27
7.3.310.0030.00516.43
7.3.300.0000.00716.34
7.3.290.0130.00416.40
7.3.280.0050.01216.36
7.3.270.0150.00617.40
7.3.260.0130.00616.37
7.3.250.0120.00516.44
7.3.240.0090.00616.48
7.3.230.0000.01616.39
7.3.210.0080.00816.61
7.3.200.0000.01619.39
7.3.190.0130.00316.36
7.3.180.0040.01116.59
7.3.170.0120.01016.56
7.3.160.0110.00616.48
7.3.120.0000.01314.82
7.3.110.0030.01315.02
7.3.100.0030.01014.99
7.3.90.0060.00914.86
7.3.80.0060.00615.02
7.3.70.0080.00814.99
7.3.60.0040.00814.94
7.3.50.0080.00414.73
7.3.40.0060.00614.71
7.3.30.0060.00614.75
7.3.20.0040.01116.61
7.3.10.0000.01016.83
7.3.00.0110.00416.82
7.2.330.0080.01216.60
7.2.320.0160.00316.75
7.2.310.0060.01016.82
7.2.300.0120.01216.50
7.2.290.0080.01116.77
7.2.250.0060.01615.25
7.2.240.0070.01315.28
7.2.230.0030.01015.28
7.2.220.0100.00314.97
7.2.210.0040.00815.20
7.2.200.0030.01514.90
7.2.190.0060.00915.10
7.2.180.0120.00314.95
7.2.170.0040.00715.20
7.2.00.0070.01019.09
7.1.330.0000.01615.76
7.1.320.0030.01215.99
7.1.310.0000.01215.91
7.1.300.0110.00415.88
7.1.290.0080.00815.92
7.1.280.0090.00615.69
7.1.270.0040.01115.79
7.1.260.0030.00515.78
7.1.100.0060.00618.05
7.1.70.0050.00317.33
7.1.60.0060.01919.11
7.1.50.0140.01017.02
7.1.00.0030.07722.45
7.0.200.0000.01016.79
7.0.140.0030.07321.93
7.0.60.0200.07020.09
7.0.50.0070.08017.89
7.0.40.0070.08320.04
7.0.30.0530.05020.06
7.0.20.0170.04320.30
7.0.10.0030.04320.02
7.0.00.0030.09320.27
5.6.280.0070.08721.09
5.6.210.0070.03720.73
5.6.200.0030.04018.29
5.6.190.0130.08320.46
5.6.180.0370.07320.43
5.6.170.0130.04720.54
5.6.160.0300.03320.57
5.6.150.0000.07718.29
5.6.140.0030.04018.17
5.6.130.0100.06718.22
5.6.120.0000.04321.06
5.6.110.0200.08021.00
5.6.100.0070.08020.99
5.6.90.0130.06021.15
5.6.80.0100.08020.46
5.6.70.0030.07720.29
5.5.350.0100.08320.44
5.5.340.0130.04718.07
5.5.330.0070.05320.38
5.5.320.0270.06020.42
5.5.310.0330.06720.43
5.5.300.0030.08718.07
5.5.290.0100.07717.93
5.5.280.0130.07320.89
5.5.270.0100.08020.78
5.5.260.0000.04320.74
5.5.250.0130.07320.63
5.5.240.0270.06720.30
5.4.450.0670.06019.56
5.4.440.0830.06719.64
5.4.430.0870.05719.63
5.4.420.0800.04719.57
5.4.410.0170.07019.57
5.4.400.0830.06018.85
5.4.390.0730.05718.86
5.4.380.0600.05319.29
5.4.370.0730.05319.26
5.4.360.0470.06019.23
5.4.350.0670.05718.84
5.4.340.0060.03512.03
5.4.320.0080.03612.52
5.4.310.0090.03612.52
5.4.300.0050.03812.52
5.4.290.0050.03912.52
5.4.280.0060.03512.41
5.4.270.0060.03912.41
5.4.260.0080.03812.41
5.4.250.0050.03912.41
5.4.240.0080.04612.41
5.4.230.0050.05012.41
5.4.220.0070.03512.41
5.4.210.0060.03712.40
5.4.200.0090.03512.41
5.4.190.0050.03812.40
5.4.180.0050.03812.40
5.4.170.0070.03512.42
5.4.160.0090.03712.41
5.4.150.0070.03712.41
5.4.140.0070.04212.09
5.4.130.0080.03312.07
5.4.120.0060.03612.03
5.4.110.0050.03812.03
5.4.100.0040.03812.03
5.4.90.0080.03512.02
5.4.80.0070.03512.03
5.4.70.0100.03712.02
5.4.60.0040.03712.03
5.4.50.0110.03112.02
5.4.40.0050.03612.01
5.4.30.0120.04412.00
5.4.20.0120.04512.00
5.4.10.0090.04212.00
5.4.00.0060.04111.49
5.3.290.0090.04012.80
5.3.280.0050.03912.71
5.3.270.0050.04112.73
5.3.260.0100.03712.72
5.3.250.0100.03312.71
5.3.240.0020.04112.72
5.3.230.0060.04012.70
5.3.220.0080.05612.68
5.3.210.0100.04412.68
5.3.200.0090.03512.68
5.3.190.0060.04312.68
5.3.180.0090.04212.68
5.3.170.0030.04112.67
5.3.160.0070.03512.67
5.3.150.0070.03612.67
5.3.140.0060.03712.66
5.3.130.0100.03412.66
5.3.120.0090.03912.66
5.3.110.0100.03912.66
5.3.100.0090.04812.12
5.3.90.0070.04112.11
5.3.80.0090.03312.09
5.3.70.0100.03712.09
5.3.60.0060.04912.08
5.3.50.0050.04512.02
5.3.40.0090.04112.02
5.3.30.0070.03611.98
5.3.20.0060.03611.77
5.3.10.0050.03811.74
5.3.00.0070.04511.71
5.2.170.0030.0329.21
5.2.160.0010.0339.22
5.2.150.0040.0329.22
5.2.140.0060.0299.21
5.2.130.0040.0349.17
5.2.120.0010.0369.17
5.2.110.0050.0319.18
5.2.100.0030.0319.18
5.2.90.0040.0379.18
5.2.80.0090.0289.18
5.2.70.0070.0309.17
5.2.60.0040.0339.13
5.2.50.0020.0349.09
5.2.40.0040.0309.07
5.2.30.0060.0299.05
5.2.20.0050.0309.05
5.2.10.0040.0308.95
5.2.00.0030.0318.81
5.1.60.0070.0218.09
5.1.50.0060.0328.09
5.1.40.0040.0268.07
5.1.30.0060.0258.42
5.1.20.0060.0268.44
5.1.10.0060.0248.16
5.1.00.0090.0328.16
5.0.50.0060.0216.64
5.0.40.0020.0226.50
5.0.30.0050.0316.31
5.0.20.0030.0206.29
5.0.10.0050.0196.26
5.0.00.0030.0376.25
4.4.90.0040.0164.78
4.4.80.0010.0184.76
4.4.70.0060.0154.75
4.4.60.0030.0174.75
4.4.50.0010.0184.77
4.4.40.0030.0254.71
4.4.30.0030.0164.76
4.4.20.0040.0214.84
4.4.10.0030.0214.85
4.4.00.0040.0254.76
4.3.110.0040.0184.67
4.3.100.0020.0164.66
4.3.90.0050.0124.63
4.3.80.0040.0244.59
4.3.70.0020.0164.63
4.3.60.0080.0114.63
4.3.50.0020.0224.63
4.3.40.0030.0244.54
4.3.30.0040.0143.30
4.3.20.0020.0163.27
4.3.10.0010.0173.24
4.3.00.0130.0236.66

preferences:
41.63 ms | 400 KiB | 5 Q