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 { arsort($array); $bins = [[]]; foreach ($array as $value) { $added = false; foreach ($bins as &$bin) { if ($capacity >= (array_sum($bin) + $value)) { $bin[] = $value; $added = true; continue 2; } } if (!$added) { $bins[] = [$value]; } } return array_map('array_sum', 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.5.10.0110.00519.34
8.5.00.0120.00922.86
8.4.150.0030.00014.05
8.4.140.0110.01217.77
8.4.130.0130.00817.75
8.4.120.0040.00520.57
8.4.110.0130.00522.60
8.4.100.0080.00517.89
8.4.90.0100.00818.69
8.4.80.0120.00618.05
8.4.70.0050.00417.80
8.4.60.0110.00918.60
8.4.50.0110.00719.51
8.4.40.0100.00720.71
8.4.30.0040.01122.10
8.4.20.0130.00717.90
8.4.10.0030.00622.04
8.3.280.0120.00818.39
8.3.270.0170.00816.69
8.3.260.0130.00716.89
8.3.250.0130.00619.00
8.3.240.0130.00816.69
8.3.230.0140.00616.68
8.3.220.0130.00617.30
8.3.210.0100.00816.84
8.3.200.0040.00516.52
8.3.190.0050.00317.17
8.3.180.0100.01016.53
8.3.170.0170.00317.29
8.3.160.0030.00517.42
8.3.150.0030.01617.21
8.3.140.0110.00719.12
8.3.130.0030.00618.46
8.3.120.0120.00320.64
8.3.110.0040.00420.94
8.3.100.0030.00724.06
8.3.90.0030.00526.77
8.3.80.0000.01217.97
8.3.70.0070.01118.33
8.3.60.0040.01118.42
8.3.50.0130.00318.57
8.3.40.0070.00720.34
8.3.30.0100.00320.91
8.3.20.0070.00024.18
8.3.10.0050.00224.66
8.3.00.0070.00026.16
8.2.290.0120.00820.64
8.2.280.0110.00818.54
8.2.270.0110.00722.49
8.2.260.0060.00316.85
8.2.250.0070.00318.36
8.2.240.0070.00317.44
8.2.230.0000.00822.58
8.2.220.0040.00737.54
8.2.210.0100.00026.77
8.2.200.0060.00317.00
8.2.190.0140.00417.00
8.2.180.0140.00718.16
8.2.170.0090.00618.99
8.2.160.0030.01022.96
8.2.150.0030.00625.66
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00419.48
8.2.110.0070.00421.08
8.2.100.0080.00417.91
8.2.90.0000.00718.22
8.2.80.0060.00320.01
8.2.70.0030.00617.50
8.2.60.0130.00517.38
8.2.50.0100.00717.21
8.2.40.0110.00617.50
8.2.30.0140.00317.25
8.2.20.0090.00917.50
8.2.10.0170.00017.38
8.2.00.0120.00417.25
8.1.330.0120.00822.11
8.1.320.0100.01216.21
8.1.310.0120.00616.50
8.1.300.0070.01416.71
8.1.290.0070.00430.84
8.1.280.0090.00925.92
8.1.270.0080.00024.66
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0080.00023.97
8.1.230.0030.00720.97
8.1.220.0080.00017.80
8.1.210.0000.00918.77
8.1.200.0090.00017.47
8.1.190.0100.00717.00
8.1.180.0050.01116.98
8.1.170.0110.00616.97
8.1.160.0060.01117.00
8.1.150.0080.01117.00
8.1.140.0100.00617.25
8.1.130.0100.00617.13
8.1.120.0110.00717.50
8.1.110.0120.00617.13
8.1.100.0090.00917.50
8.1.90.0080.00817.13
8.1.80.0100.00717.13
8.1.70.0150.00317.38
8.1.60.0100.00817.23
8.1.50.0100.01017.12
8.1.40.0160.00317.25
8.1.30.0140.00517.25
8.1.20.0140.00517.38
8.1.10.0120.00917.50
8.1.00.0050.01517.13
8.0.300.0040.00420.03
8.0.290.0040.00416.75
8.0.280.0110.00816.73
8.0.270.0160.00316.63
8.0.260.0110.00616.52
8.0.250.0160.00016.75
8.0.240.0120.00416.74
8.0.230.0170.00016.63
8.0.220.0070.00716.52
8.0.210.0140.00316.75
8.0.200.0160.00316.75
8.0.190.0100.00716.52
8.0.180.0100.00716.52
8.0.170.0150.00016.52
8.0.160.0120.00216.52
8.0.150.0140.00016.52
8.0.140.0070.00716.52
8.0.130.0100.00316.52
8.0.120.0050.00916.52
8.0.110.0120.00316.52
8.0.100.0110.00416.52
8.0.90.0150.00016.52
8.0.80.0140.00016.52
8.0.70.0100.00516.52
8.0.60.0140.00016.52
8.0.50.0160.00016.52
8.0.30.0120.00016.52
8.0.20.0150.00016.73
8.0.10.0130.00316.52

preferences:
108.56 ms | 403 KiB | 5 Q