3v4l.org

run code in 300+ PHP versions simultaneously
<?php $weight_distribution = [ '5' => 0, '10' => 6, '15' => 7, '20' => 3, ]; function distribute_weights($weight, &$distribution) { while ($weight > 0) { foreach ($distribution as $max => $count) { if ($weight <= $max) { break; } } ++$distribution[$max]; $weight -= $max; } } distribute_weights(21, $weight_distribution); var_export($weight_distribution);

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.00.0110.01220.04
8.4.150.0020.00014.05
8.4.140.0130.00817.53
8.4.130.0060.00617.77
8.4.120.0110.00824.05
8.4.110.0080.01221.34
8.4.100.0060.00318.85
8.4.90.0140.00718.46
8.4.80.0040.00420.38
8.4.70.0110.01017.93
8.4.60.0120.00818.67
8.4.50.0140.00718.48
8.4.40.0200.00018.55
8.4.30.0040.01120.56
8.4.20.0070.01119.48
8.4.10.0040.01219.14
8.3.280.0110.01218.32
8.3.270.0160.00916.58
8.3.260.0140.00617.34
8.3.250.0140.00618.82
8.3.240.0130.00717.29
8.3.230.0110.00916.88
8.3.220.0140.00419.16
8.3.210.0070.01116.68
8.3.200.0050.00416.50
8.3.190.0090.01017.17
8.3.180.0080.01017.11
8.3.170.0090.00022.48
8.3.160.0090.00917.27
8.3.150.0120.00617.25
8.3.140.0040.00417.27
8.3.130.0080.00018.50
8.3.120.0090.00018.81
8.3.110.0080.00320.94
8.3.100.0040.00424.06
8.3.90.0050.00326.77
8.3.80.0060.00318.18
8.3.70.0040.01118.31
8.3.60.0470.00725.92
8.3.50.0110.01125.92
8.3.40.0200.02425.92
8.3.30.0320.01125.92
8.3.20.0360.00725.92
8.3.10.0380.00825.92
8.3.00.0350.01025.92
8.2.290.0150.00420.32
8.2.280.0080.01218.34
8.2.270.0100.01018.84
8.2.260.0030.00618.30
8.2.250.0050.00316.85
8.2.240.0070.01016.99
8.2.230.0030.00622.58
8.2.220.0080.00037.54
8.2.210.0120.00626.77
8.2.200.0000.00816.88
8.2.190.0110.00416.58
8.2.180.0370.00925.92
8.2.170.0460.00425.92
8.2.160.0370.01225.92
8.2.150.0450.01025.92
8.2.140.0440.00325.92
8.2.130.0440.00725.92
8.2.120.0340.01225.92
8.2.110.0350.01025.92
8.2.100.0370.00425.92
8.2.90.0460.00325.92
8.2.80.0440.00425.92
8.2.70.0270.01725.92
8.2.60.0270.01625.92
8.2.50.0320.00925.92
8.2.40.0230.01125.92
8.2.30.0290.00325.92
8.2.20.0480.00425.92
8.2.10.0270.01825.92
8.2.00.0380.00725.92
8.1.330.0120.00722.03
8.1.320.0120.00816.40
8.1.310.0080.00016.47
8.1.300.0050.00320.01
8.1.290.0040.00430.84
8.1.280.0330.01225.92
8.1.270.0370.01425.92
8.1.260.0410.01025.92
8.1.250.0380.00825.92
8.1.240.0320.00425.92
8.1.230.0260.01025.92
8.1.220.0320.00425.92
8.1.210.0160.01925.92
8.1.200.0300.00625.92
8.1.190.0250.01125.92
8.1.180.0360.00325.92
8.1.170.0400.00325.92
8.1.160.0340.00925.92
8.1.150.0430.00425.92
8.1.140.0360.01025.92
8.1.130.0340.00425.92
8.1.120.0340.00025.92
8.1.110.0240.01425.92
8.1.100.0220.00925.92
8.1.90.0360.00925.92
8.1.80.0430.00725.92
8.1.70.0260.00725.92
8.1.60.0240.00825.92
8.1.50.0300.00425.92
8.1.40.0290.00425.92
8.1.30.0540.01025.92
8.1.20.0410.00025.92
8.1.10.0310.00325.92
8.1.00.0270.00625.92

preferences:
34.08 ms | 403 KiB | 5 Q