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_unshift($ys, $x), $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); list($ys, $zs) = span($eq($x), $xs); } function it($m,$p){echo ($p?'✔︎':'✘')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);} var_dump(span(function ($x) { return $x < 2; }, [1, 2, 3]));

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.0170.00018.30
8.3.50.0060.01216.49
8.3.40.0120.00618.72
8.3.30.0070.00719.10
8.3.20.0040.00420.22
8.3.10.0090.00023.66
8.3.00.0030.00619.38
8.2.180.0040.01116.75
8.2.170.0110.00422.96
8.2.160.0070.00720.47
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0050.00322.30
8.2.110.0090.00020.35
8.2.100.0000.01118.03
8.2.90.0050.00319.17
8.2.80.0050.00317.97
8.2.70.0040.00417.63
8.2.60.0060.00317.93
8.2.50.0040.00418.07
8.2.40.0050.00319.94
8.2.30.0000.00718.18
8.2.20.0000.00717.71
8.2.10.0000.00818.13
8.2.00.0040.00417.69
8.1.280.0180.00025.92
8.1.270.0030.00621.96
8.1.260.0070.00026.35
8.1.250.0000.00828.09
8.1.240.0060.00323.91
8.1.230.0040.00719.16
8.1.220.0060.00317.74
8.1.210.0060.00318.77
8.1.200.0060.00317.35
8.1.190.0040.00417.23
8.1.180.0000.00818.10
8.1.170.0000.00818.46
8.1.160.0000.00821.98
8.1.150.0030.00518.91
8.1.140.0050.00217.46
8.1.130.0000.00717.80
8.1.120.0040.00417.51
8.1.110.0000.00717.46
8.1.100.0040.00417.45
8.1.90.0000.00717.43
8.1.80.0040.00417.42
8.1.70.0030.00317.35
8.1.60.0050.00317.59
8.1.50.0080.00017.43
8.1.40.0060.00317.42
8.1.30.0000.00917.64
8.1.20.0030.00517.64
8.1.10.0060.00317.57
8.1.00.0040.00417.41
8.0.300.0050.00318.77
8.0.290.0000.00716.88
8.0.280.0070.00018.47
8.0.270.0050.00517.23
8.0.260.0000.00617.30
8.0.250.0070.00016.94
8.0.240.0080.00016.99
8.0.230.0030.00317.02
8.0.220.0000.00816.80
8.0.210.0000.00716.95
8.0.200.0000.00616.95
8.0.190.0060.00317.00
8.0.180.0000.00716.93
8.0.170.0040.00416.88
8.0.160.0050.00316.84
8.0.150.0000.00816.76
8.0.140.0000.00716.78
8.0.130.0030.00313.41
8.0.120.0030.00616.87
8.0.110.0080.00016.89
8.0.100.0000.00716.83
8.0.90.0040.00416.71
8.0.80.0150.00016.90
8.0.70.0000.00716.75
8.0.60.0000.00716.89
8.0.50.0070.00016.95
8.0.30.0080.01517.28
8.0.20.0130.00617.40
8.0.10.0040.00417.04
8.0.00.0100.00816.79
7.4.330.0020.00215.00
7.4.320.0030.00316.51
7.4.300.0000.00616.54
7.4.290.0000.00716.52
7.4.280.0060.00316.54
7.4.270.0000.00716.62
7.4.260.0050.00216.61
7.4.250.0040.00416.60
7.4.240.0030.00316.49
7.4.230.0070.00016.28
7.4.220.0140.00416.40
7.4.210.0030.01016.71
7.4.200.0070.00016.56
7.4.160.0100.00616.37
7.4.150.0110.00717.40
7.4.140.0060.01217.86
7.4.130.0130.00516.48
7.4.120.0080.00916.41
7.4.110.0120.00616.71
7.4.100.0030.01316.48
7.4.90.0160.00616.70
7.4.80.0140.00819.39
7.4.70.0080.00816.47
7.4.60.0130.00316.70
7.4.50.0040.00416.79
7.4.40.0050.01116.32
7.4.30.0080.01216.64
7.4.00.0040.01415.29
7.3.330.0060.00013.34
7.3.320.0030.00313.22
7.3.310.0000.00716.43
7.3.300.0000.00616.34
7.3.290.0060.01116.37
7.3.280.0060.01016.38
7.3.270.0170.00317.40
7.3.260.0060.01516.36
7.3.250.0050.01116.61
7.3.240.0050.01416.51
7.3.230.0120.00616.40
7.3.210.0100.01016.42
7.3.200.0130.00419.39
7.3.190.0090.01316.35
7.3.180.0130.00316.62
7.3.170.0110.00816.39
7.3.160.0030.01216.37
7.3.120.0110.00714.94
7.3.110.0100.00315.01
7.3.100.0100.00314.94
7.3.90.0030.01414.67
7.3.80.0120.00415.19
7.3.70.0030.01014.81
7.3.60.0030.00914.86
7.3.50.0070.01014.81
7.3.40.0060.00914.87
7.3.30.0130.00014.97
7.3.20.0090.00616.59
7.3.10.0060.00916.73
7.3.00.0070.00716.80
7.2.330.0090.00916.57
7.2.320.0110.01116.39
7.2.310.0130.00316.61
7.2.300.0090.01216.77
7.2.290.0090.00916.63
7.2.240.0000.01614.86
7.2.230.0070.00715.20
7.2.220.0030.01315.32
7.2.210.0060.00915.35
7.2.200.0000.01315.12
7.2.190.0040.01014.87
7.2.180.0060.00614.97
7.2.170.0060.00614.74
7.2.160.0040.01214.97
7.2.150.0080.00416.84
7.2.140.0060.01117.07
7.2.130.0040.00717.18
7.2.120.0090.00916.97
7.2.110.0060.00917.00
7.2.100.0060.00916.95
7.2.90.0060.00917.16
7.2.80.0040.00717.04
7.2.70.0090.00616.64
7.2.60.0140.00416.84
7.2.50.0040.01116.86
7.2.40.0140.00017.08
7.2.30.0070.00716.89
7.2.20.0030.01017.14
7.2.10.0120.00616.88
7.2.00.0050.01118.18
7.1.330.0060.01015.84
7.1.320.0000.01215.68
7.1.310.0070.01115.53
7.1.300.0070.01015.89
7.1.290.0070.01015.57
7.1.280.0040.01115.81
7.1.270.0030.01415.51
7.1.260.0090.00415.71
7.1.250.0000.01815.89
7.1.100.0000.01218.05
7.1.70.0000.01016.97
7.1.60.0040.00719.11
7.1.50.0100.01317.07
7.1.00.0000.08022.35
7.0.200.0030.00616.82
7.0.140.0070.07021.92
7.0.60.0000.05719.84
7.0.50.0000.08317.88
7.0.40.0130.08020.11
7.0.30.0130.04320.21
7.0.20.0300.07020.05
7.0.10.0200.05720.09
7.0.00.0070.06320.15
5.6.280.0100.06320.93
5.6.210.0100.07720.48
5.6.200.0070.06018.30
5.6.190.0070.08320.52
5.6.180.3270.04720.44
5.6.170.0430.06720.45
5.6.160.0030.08720.54
5.6.150.0070.08018.15
5.6.140.0100.04718.25
5.6.130.0030.08318.18
5.6.120.0100.08021.13
5.6.110.0070.08021.13
5.6.100.0030.07320.98
5.6.90.0130.08721.12
5.6.80.0000.04320.48
5.6.70.4300.04720.43
5.5.350.0230.08020.48
5.5.340.0100.03317.97
5.5.330.0070.08020.31
5.5.320.0270.08020.32
5.5.310.0300.06020.34
5.5.300.0030.03717.97
5.5.290.0070.03717.98
5.5.280.0070.07020.91
5.5.270.0030.04320.88
5.5.260.0030.04020.88
5.5.250.0070.05020.59
5.5.240.0000.09320.36
5.4.450.1100.04719.52
5.4.440.0700.05719.32
5.4.430.0770.04719.20
5.4.420.0700.00019.41
5.4.410.0670.00019.46
5.4.400.0670.00019.02
5.4.390.0630.00019.11
5.4.380.0670.00019.09
5.4.370.0630.00019.06
5.4.360.0830.00019.11
5.4.350.0670.00019.03
5.4.340.0070.03512.03
5.4.320.0100.03412.51
5.4.310.0060.04212.51
5.4.300.0090.03812.52
5.4.290.0110.04412.51
5.4.280.0080.03712.41
5.4.270.0070.04412.41
5.4.260.0060.04112.41
5.4.250.0070.03712.41
5.4.240.0080.04512.41
5.4.230.0060.03812.40
5.4.220.0070.03912.40
5.4.210.0060.04012.40
5.4.200.0100.04112.40
5.4.190.0080.05412.40
5.4.180.0090.04412.39
5.4.170.0060.03812.41
5.4.160.0030.04012.40
5.4.150.0050.03712.39
5.4.140.0080.03712.08
5.4.130.0120.04512.07
5.4.120.0080.04512.03
5.4.110.0060.04512.02
5.4.100.0100.03812.02
5.4.90.0040.04412.02
5.4.80.0080.04212.02
5.4.70.0080.03312.02
5.4.60.0080.03412.02
5.4.50.0070.03212.01
5.4.40.0050.03612.01
5.4.30.0050.03712.00
5.4.20.0040.03712.00
5.4.10.0050.03512.00
5.4.00.0080.03411.49
5.3.290.0040.04112.80
5.3.280.0070.04212.71
5.3.270.0080.04612.72
5.3.260.0090.03612.72
5.3.250.0090.03312.72
5.3.240.0040.03912.72
5.3.230.0060.04512.71
5.3.220.0060.03912.68
5.3.210.0080.03812.68
5.3.200.0060.03612.68
5.3.190.0050.04112.68
5.3.180.0040.03912.67
5.3.170.0070.03812.67
5.3.160.0050.03912.68
5.3.150.0070.03912.68
5.3.140.0070.03712.66
5.3.130.0080.03512.66
5.3.120.0090.04712.66
5.3.110.0080.04112.66
5.3.100.0050.04012.13
5.3.90.0060.03612.11
5.3.80.0070.03612.09
5.3.70.0050.03812.09
5.3.60.0070.04112.09
5.3.50.0070.03512.02
5.3.40.0050.03712.02
5.3.30.0060.03511.98
5.3.20.0100.03711.76
5.3.10.0050.03811.74
5.3.00.0060.03611.72
5.2.170.0030.0329.21
5.2.160.0040.0319.21
5.2.150.0050.0329.21
5.2.140.0020.0369.21
5.2.130.0060.0329.18
5.2.120.0040.0329.17
5.2.110.0080.0289.18
5.2.100.0040.0319.18
5.2.90.0090.0269.18
5.2.80.0040.0329.18
5.2.70.0040.0329.18
5.2.60.0070.0329.13
5.2.50.0050.0319.09
5.2.40.0050.0299.07
5.2.30.0020.0339.05
5.2.20.0040.0309.04
5.2.10.0060.0308.95
5.2.00.0050.0308.81
5.1.60.0050.0298.09
5.1.50.0060.0248.08
5.1.40.0020.0278.06
5.1.30.0020.0288.43
5.1.20.0010.0298.44
5.1.10.0080.0258.16
5.1.00.0050.0248.17
5.0.50.0010.0266.64
5.0.40.0030.0196.50
5.0.30.0040.0306.31
5.0.20.0040.0196.28
5.0.10.0020.0216.26
5.0.00.0040.0326.25
4.4.90.0040.0174.78
4.4.80.0020.0164.75
4.4.70.0010.0174.76
4.4.60.0030.0164.76
4.4.50.0060.0154.77
4.4.40.0030.0294.71
4.4.30.0030.0154.76
4.4.20.0030.0174.85
4.4.10.0010.0224.85
4.4.00.0010.0294.76
4.3.110.0000.0194.67
4.3.100.0040.0194.66
4.3.90.0020.0154.63
4.3.80.0050.0294.58
4.3.70.0060.0174.63
4.3.60.0040.0154.63
4.3.50.0000.0194.63
4.3.40.0020.0324.54
4.3.30.0030.0203.30
4.3.20.0020.0213.28
4.3.10.0040.0273.24
4.3.00.0070.01012.08

preferences:
52.06 ms | 400 KiB | 5 Q