3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 0 => 50, 1 => 200, 2 => 75, 3 => 150, 4 => 100, 5 => 125, 6 => 150, 7 => 300, 8 => 300, 9 => 300, 10 => 300, 11 => 300, 12 => 300, 13 => 300, 14 => 300, 15 => 300, ]; function consolidate(array $array, int $capacity = 500): array { rsort($array); $bins = [0]; foreach ($array as $value) { foreach ($bins as &$bin) { if ($capacity >= $bin + $value) { $bin += $value; continue 2; } } $bins[] = $value; } return array_values(array_filter($bins)); } var_export(consolidate($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.4.140.0120.00917.39
8.4.130.0120.00917.68
8.4.120.0110.00922.26
8.4.110.0110.01018.85
8.4.100.0050.00518.66
8.4.90.0120.00818.58
8.4.80.0050.00418.03
8.4.70.0090.01018.11
8.4.60.0100.01418.80
8.4.50.0090.01119.53
8.4.40.0160.00620.52
8.4.30.0140.00419.97
8.4.20.0210.00617.55
8.4.10.0220.00620.08
8.3.270.0120.00816.48
8.3.260.0110.00916.68
8.3.250.0110.00818.95
8.3.240.0110.00816.43
8.3.230.0150.00516.70
8.3.220.0040.00417.37
8.3.210.0100.00816.54
8.3.200.0040.00516.69
8.3.190.0110.00717.09
8.3.180.0050.00316.74
8.3.170.0160.00317.28
8.3.160.0240.00917.50
8.3.150.0170.01518.79
8.3.140.0230.00517.99
8.3.130.0270.00318.46
8.3.120.0190.00417.68
8.3.110.0110.00818.77
8.3.100.0150.00320.30
8.3.90.0130.00121.76
8.3.80.0150.00417.48
8.3.70.0160.00117.55
8.3.60.0130.00417.43
8.3.50.0110.00616.55
8.3.40.0220.00518.81
8.3.30.0200.00519.23
8.3.20.0140.00620.90
8.3.10.0200.00021.08
8.3.00.0120.00521.83
8.2.290.0110.00820.36
8.2.280.0100.01018.63
8.2.270.0160.00917.12
8.2.260.0180.01017.47
8.2.250.0220.00516.48
8.2.240.0160.01417.83
8.2.230.0190.00219.53
8.2.220.0200.00327.10
8.2.210.0170.00621.54
8.2.200.0170.00816.51
8.2.190.0250.00316.60
8.2.180.0210.00621.10
8.2.170.0220.00718.34
8.2.160.0170.00820.45
8.2.150.0080.00921.71
8.2.140.0200.00221.06
8.2.130.0130.01121.70
8.2.120.0200.00618.46
8.2.110.0170.01318.97
8.2.100.0210.00317.76
8.2.90.0220.00217.82
8.2.80.0190.00418.15
8.2.70.0170.00617.63
8.2.60.0220.00717.25
8.2.50.0200.01017.38
8.2.40.0200.00517.54
8.2.30.0170.00817.40
8.2.20.0230.00317.48
8.2.10.0220.00717.51
8.2.00.0210.00617.49
8.1.330.0110.00722.11
8.1.320.0130.00616.11
8.1.310.0190.00917.31
8.1.300.0150.00917.09
8.1.290.0160.00823.46
8.1.280.0200.00920.88
8.1.270.0210.00320.83
8.1.260.0220.00421.70
8.1.250.0210.00222.58
8.1.240.0210.00218.02
8.1.230.0230.00119.16
8.1.220.0150.00717.51
8.1.210.0150.01018.01
8.1.200.0160.00817.25
8.1.190.0190.00717.27
8.1.180.0180.00717.07
8.1.170.0170.00617.16
8.1.160.0210.00517.34
8.1.150.0220.00517.16
8.1.140.0190.00717.24
8.1.130.0180.01017.22
8.1.120.0210.00617.28
8.1.110.0240.00417.30
8.1.100.0210.00617.05
8.1.90.0200.00717.20
8.1.80.0170.00917.12
8.1.70.0210.00517.22
8.1.60.0170.01017.24
8.1.50.0220.00417.24
8.1.40.0220.00217.47
8.1.30.0120.01217.28
8.1.20.0200.00817.41
8.1.10.0200.00617.32
8.1.00.0220.00317.23
8.0.300.0100.00517.72
8.0.290.0160.00616.69
8.0.280.0180.00916.65
8.0.270.0180.00816.54
8.0.260.0240.00516.54
8.0.250.0240.00316.68
8.0.240.0250.00116.66
8.0.230.0200.00716.52
8.0.220.0250.00216.58
8.0.210.0250.00416.54
8.0.200.0220.00416.55
8.0.190.0230.00316.54
8.0.180.0210.00716.70
8.0.170.0220.00416.64
8.0.160.0230.00416.67
8.0.150.0270.00116.69
8.0.140.0220.00016.57
8.0.130.0200.00316.83
8.0.120.0240.00316.53
8.0.110.0210.00516.54
8.0.100.0200.00716.44
8.0.90.0230.00516.54
8.0.80.0190.01016.57
8.0.70.0210.00616.73
8.0.60.0220.00416.55
8.0.50.0160.01016.75
8.0.30.0190.00816.65
8.0.20.0200.00616.79
8.0.10.0220.00516.63

preferences:
28.54 ms | 403 KiB | 5 Q