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);} it('spans elements', span(function ($x) { return $x < 2; }, [1, 2, 3]) === [[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.0110.00716.50
8.3.50.0100.01022.04
8.3.40.0100.00718.73
8.3.30.0140.00019.05
8.3.20.0040.00420.16
8.3.10.0000.00823.48
8.3.00.0040.00419.13
8.2.180.0060.00916.50
8.2.170.0110.00422.96
8.2.160.0090.00620.39
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0030.00522.23
8.2.110.0060.00320.57
8.2.100.0060.00618.22
8.2.90.0000.00819.21
8.2.80.0000.00817.97
8.2.70.0000.00817.75
8.2.60.0040.00417.93
8.2.50.0090.00018.07
8.2.40.0050.00319.88
8.2.30.0070.00018.13
8.2.20.0030.00517.68
8.2.10.0070.00018.20
8.2.00.0000.00817.66
8.1.280.0070.01425.92
8.1.270.0080.00022.14
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0050.00523.97
8.1.230.0000.01218.97
8.1.220.0090.00017.79
8.1.210.0030.00618.77
8.1.200.0030.00617.25
8.1.190.0000.00917.23
8.1.180.0000.00918.10
8.1.170.0090.00018.59
8.1.160.0070.00021.92
8.1.150.0000.00718.78
8.1.140.0050.00317.38
8.1.130.0000.00717.83
8.1.120.0050.00217.52
8.1.110.0040.00417.38
8.1.100.0040.00417.48
8.1.90.0080.00017.35
8.1.80.0000.00717.51
8.1.70.0040.00417.41
8.1.60.0000.00817.62
8.1.50.0040.00417.43
8.1.40.0040.00417.49
8.1.30.0040.00417.65
8.1.20.0040.00417.63
8.1.10.0060.00317.61
8.1.00.0040.00417.48
8.0.300.0060.00318.77
8.0.290.0000.00816.88
8.0.280.0070.00018.33
8.0.270.0080.00017.21
8.0.260.0000.00717.30
8.0.250.0070.00016.84
8.0.240.0030.00616.96
8.0.230.0000.00817.00
8.0.220.0030.00616.79
8.0.210.0040.00416.89
8.0.200.0000.00616.86
8.0.190.0070.00716.97
8.0.180.0070.00016.92
8.0.170.0060.00316.86
8.0.160.0000.00717.02
8.0.150.0040.00416.78
8.0.140.0070.00016.89
8.0.130.0000.00513.28
8.0.120.0000.01016.89
8.0.110.0000.00816.82
8.0.100.0000.00816.84
8.0.90.0040.00416.91
8.0.80.0100.01016.80
8.0.70.0000.00716.96
8.0.60.0050.00316.98
8.0.50.0050.00316.82
8.0.30.0120.00817.07
8.0.20.0120.00917.40
8.0.10.0040.00417.06
8.0.00.0120.00616.78
7.4.330.0000.00515.00
7.4.320.0000.00716.60
7.4.300.0000.00616.53
7.4.290.0070.00016.41
7.4.280.0040.00716.41
7.4.270.0070.00016.54
7.4.260.0000.00716.53
7.4.250.0040.00416.62
7.4.240.0020.00516.62
7.4.230.0000.00716.43
7.4.220.0060.01916.51
7.4.210.0080.00516.62
7.4.200.0030.00516.42
7.4.160.0000.01616.68
7.4.150.0060.01217.40
7.4.140.0090.00917.86
7.4.130.0080.01016.58
7.4.120.0130.00816.63
7.4.110.0110.00616.61
7.4.100.0060.01216.62
7.4.90.0150.00316.62
7.4.80.0060.01019.39
7.4.70.0030.01316.47
7.4.60.0100.00716.54
7.4.50.0020.00216.30
7.4.40.0060.00916.50
7.4.30.0130.00716.46
7.4.10.0170.00015.15
7.4.00.0030.01314.94
7.3.330.0060.00013.16
7.3.320.0030.00313.30
7.3.310.0030.00316.43
7.3.300.0000.00616.33
7.3.290.0080.00616.40
7.3.280.0090.01016.41
7.3.270.0070.01117.40
7.3.260.0070.01116.39
7.3.250.0100.00616.48
7.3.240.0120.00916.46
7.3.230.0130.00916.48
7.3.210.0100.00616.58
7.3.200.0060.00919.39
7.3.190.0080.00916.61
7.3.180.0070.01016.34
7.3.170.0110.00616.60
7.3.160.0090.00616.42
7.3.130.0030.01315.02
7.3.120.0030.01015.11
7.3.110.0090.00915.14
7.3.100.0070.00714.58
7.3.90.0130.00014.83
7.3.80.0000.01414.74
7.3.70.0000.00914.88
7.3.60.0070.00715.00
7.3.50.0060.00614.85
7.3.40.0130.00314.73
7.3.30.0000.01214.78
7.3.20.0150.00416.64
7.3.10.0030.01316.59
7.3.00.0040.01116.80
7.2.330.0060.01216.44
7.2.320.0030.01316.50
7.2.310.0060.00916.50
7.2.300.0100.00616.81
7.2.290.0120.00616.87
7.2.260.0100.01014.94
7.2.250.0040.01515.21
7.2.240.0000.01515.21
7.2.230.0000.01014.98
7.2.220.0060.00915.21
7.2.210.0060.00314.75
7.2.200.0070.00415.16
7.2.190.0030.01015.12
7.2.180.0030.01314.97
7.2.170.0000.01414.98
7.2.160.0060.00615.06
7.2.150.0140.00316.60
7.2.140.0040.01116.80
7.2.130.0000.01216.72
7.2.120.0030.00716.99
7.2.110.0080.00317.14
7.2.100.0040.01116.76
7.2.90.0030.01016.85
7.2.80.0060.01016.93
7.2.70.0040.01517.09
7.2.60.0050.01017.06
7.2.50.0060.00317.14
7.2.40.0060.01016.88
7.2.30.0060.01317.01
7.2.20.0070.00717.04
7.2.10.0040.01417.07
7.2.00.0080.00918.32
7.1.330.0000.01615.81
7.1.320.0000.00915.77
7.1.310.0000.01415.78
7.1.300.0030.00915.81
7.1.290.0040.00715.88
7.1.280.0070.00715.79
7.1.270.0080.01115.77
7.1.260.0040.01015.53
7.1.250.0030.00915.80
7.1.240.0030.01315.76
7.1.230.0100.00715.93
7.1.220.0000.01415.63
7.1.210.0030.01015.75
7.1.200.0050.00415.88
7.1.190.0060.00915.85
7.1.180.0030.01016.01
7.1.170.0040.00415.68
7.1.160.0060.01315.55
7.1.150.0070.01015.71
7.1.140.0100.00315.87
7.1.130.0110.00715.69
7.1.120.0080.00815.83
7.1.110.0060.00615.78
7.1.100.0050.00716.92
7.1.90.0060.00915.95
7.1.80.0080.00815.85
7.1.70.0020.00916.51
7.1.60.0040.00617.33
7.1.50.0050.01216.18
7.1.40.0070.00715.54
7.1.30.0030.00715.63
7.1.20.0040.01115.84
7.1.10.0060.00615.82
7.1.00.0030.04519.02
7.0.330.0090.00315.32
7.0.320.0110.00415.53
7.0.310.0030.01015.19
7.0.300.0000.01615.49
7.0.290.0090.00915.47
7.0.280.0000.01715.42
7.0.270.0090.00615.11
7.0.260.0000.01315.43
7.0.250.0030.00715.40
7.0.240.0070.00715.60
7.0.230.0030.01415.39
7.0.220.0030.00715.25
7.0.210.0080.00415.58
7.0.200.0020.01016.05
7.0.190.0100.00715.64
7.0.180.0070.01015.25
7.0.170.0040.00415.23
7.0.160.0040.00815.23
7.0.150.0000.01415.64
7.0.140.0100.03718.68
7.0.130.0080.00315.63
7.0.120.0060.00615.23
7.0.110.0060.00815.50
7.0.100.0080.00815.43
7.0.90.0030.01015.43
7.0.80.0000.00815.56
7.0.70.0040.00415.37
7.0.60.0190.03317.89
7.0.50.0050.03916.85
7.0.40.0060.03616.70
7.0.30.0170.02716.90
7.0.20.0180.04016.78
7.0.10.0050.02316.66
7.0.00.0050.02616.97
5.6.400.0030.01214.38
5.6.390.0110.00414.55
5.6.380.0070.00414.45
5.6.370.0040.01414.33
5.6.360.0040.01114.45
5.6.350.0140.00314.41
5.6.340.0050.00514.50
5.6.330.0150.00314.40
5.6.320.0070.00714.58
5.6.310.0090.00014.76
5.6.300.0070.00314.29
5.6.290.0070.01014.32
5.6.280.0020.04517.66
5.6.270.0060.00314.57
5.6.260.0100.00314.53
5.6.250.0040.01114.32
5.6.240.0030.01414.45
5.6.230.0000.00914.59
5.6.220.0080.00414.43
5.6.210.0070.04417.54
5.6.200.0080.03316.35
5.6.190.0060.02317.45
5.6.180.0150.03017.42
5.6.170.0710.03317.48
5.6.160.0060.02817.41
5.6.150.0130.02716.28
5.6.140.0050.04216.34
5.6.130.0060.02916.34
5.6.120.0090.02017.69
5.6.110.0070.04817.68
5.6.100.0100.04317.73
5.6.90.0110.03717.78
5.6.80.0050.03117.54
5.6.70.0070.01114.32
5.6.60.0060.00614.32
5.6.50.0040.00714.47
5.6.40.0030.01114.63
5.6.30.0040.01114.68
5.6.20.0080.00414.61
5.6.10.0000.01114.60
5.6.00.0110.00414.45
5.5.380.0120.00414.35
5.5.370.0000.01314.39
5.5.360.0060.00614.36
5.5.350.0190.03517.52
5.5.340.0080.04416.21
5.5.330.0070.02517.28
5.5.320.0200.03217.17
5.5.310.0170.03717.42
5.5.300.0090.04616.17
5.5.290.0080.02016.15
5.5.280.0130.04117.62
5.5.270.0110.04317.71
5.5.260.0020.04717.78
5.5.250.0090.03517.47
5.5.240.0200.03417.40
5.5.230.0060.00914.32
5.5.220.0080.00614.31
5.5.210.0030.01014.34
5.5.200.0030.00914.34
5.5.190.0100.00714.38
5.5.180.0000.01014.45
5.5.170.0140.00414.36
5.5.160.0000.01114.30
5.5.150.0060.00914.58
5.5.140.0090.00314.47
5.5.130.0030.01014.22
5.5.120.0110.00714.31
5.5.110.0110.00414.09
5.5.100.0080.00814.23
5.5.90.0040.01114.27
5.5.80.0030.01014.31
5.5.70.0100.00714.19
5.5.60.0080.00814.26
5.5.50.0090.00614.07
5.5.40.0070.01014.39
5.5.30.0000.01714.68
5.5.20.0000.01514.53
5.5.10.0030.01314.28
5.5.00.0030.01113.94
5.4.450.0150.04215.46
5.4.440.0210.03515.52
5.4.430.0200.02515.56
5.4.420.0170.02315.60
5.4.410.0160.02415.46
5.4.400.0180.02615.45
5.4.390.0150.02915.41
5.4.380.0180.02215.36
5.4.370.0170.03315.31
5.4.360.0190.02915.43
5.4.350.0220.02015.35
5.4.340.0200.02915.43
5.4.330.0000.01311.64
5.4.320.0120.02715.44
5.4.310.0140.02215.43
5.4.300.0200.03515.25
5.4.290.0120.03415.35
5.4.280.0150.02515.26
5.4.270.0160.03415.41
5.4.260.0130.04515.47
5.4.250.0100.02615.36
5.4.240.0180.03815.43
5.4.230.0210.03315.47
5.4.220.0180.04215.25
5.4.210.0200.03815.35
5.4.200.0180.03615.36
5.4.190.0140.02615.42
5.4.180.0130.03415.45
5.4.170.0100.03215.24
5.4.160.0130.02315.39
5.4.150.0120.03715.31
5.4.140.0150.02514.03
5.4.130.0180.03414.02
5.4.120.0110.02614.04
5.4.110.0110.02114.13
5.4.100.0170.01413.94
5.4.90.0080.02314.13
5.4.80.0120.01914.09
5.4.70.0100.02213.94
5.4.60.0100.01913.95
5.4.50.0150.03414.09
5.4.40.0120.02014.06
5.4.30.0120.02314.03
5.4.20.0150.01814.08
5.4.10.0150.01813.95
5.4.00.0090.02313.86
5.3.290.0130.04714.78
5.3.280.0200.05314.52
5.3.270.0330.06014.68
5.3.260.0270.05314.52
5.3.250.0270.07714.61
5.3.240.0330.07014.68
5.3.230.0270.06314.76
5.3.220.0130.04014.73
5.3.210.0170.05014.57
5.3.200.0130.04014.56
5.3.190.0170.03714.62
5.3.180.0170.04714.47
5.3.170.0200.04314.64
5.3.160.0130.04014.72
5.3.150.0200.04314.54
5.3.140.0200.03714.60
5.3.130.0230.03014.57
5.3.120.0200.04014.60
5.3.110.0170.03714.60
5.3.100.0200.03314.20
5.3.90.0200.03314.03
5.3.80.0170.03714.10
5.3.70.0270.02713.91
5.3.60.0170.03714.12
5.3.50.0230.03013.92
5.3.40.0170.04013.95
5.3.30.0200.04013.98
5.3.20.0230.03013.61
5.3.10.0170.03313.56
5.3.00.0230.03013.75
5.2.170.0200.02712.12
5.2.160.0230.02712.12
5.2.150.0130.03012.13
5.2.140.0170.03712.13
5.2.130.0170.03012.15
5.2.120.0100.03312.15
5.2.110.0200.02712.17
5.2.100.0130.03012.18
5.2.90.0200.04012.18
5.2.80.0200.02312.18
5.2.70.0200.04712.20
5.2.60.0170.03012.20
5.2.50.0130.03012.20
5.2.40.0070.03312.20
5.2.30.0130.02712.20
5.2.20.0130.02712.20
5.2.10.0130.03312.21
5.2.00.0170.02712.22
5.1.60.0200.03012.22
5.1.50.0130.03312.23
5.1.40.0170.05012.24
5.1.30.0200.05312.24
5.1.20.0200.04312.24
5.1.10.0170.03312.24
5.1.00.0170.03012.26
5.0.50.0130.03712.27
5.0.40.0130.03012.27
5.0.30.0070.04712.28
5.0.20.0070.05012.28
5.0.10.0070.02712.28
5.0.00.0070.04012.28
4.4.90.0100.01312.20
4.4.80.0100.01012.20
4.4.70.0100.01012.20
4.4.60.0030.01712.20
4.4.50.0070.01712.20
4.4.40.0070.03712.22
4.4.30.0100.03012.23
4.4.20.0170.03012.24
4.4.10.0130.01312.27
4.4.00.0130.05012.27
4.3.110.0100.03712.28
4.3.100.0130.03312.28
4.3.90.0100.02712.28
4.3.80.0070.02712.29
4.3.70.0070.03012.29
4.3.60.0100.02312.30
4.3.50.0100.02312.30
4.3.40.0070.03012.31
4.3.30.0000.02012.32
4.3.20.0030.01712.32
4.3.10.0030.03712.32
4.3.00.0100.02012.33

preferences:
42.98 ms | 401 KiB | 5 Q