Documentation
¶
Overview ¶
Package apportion divides an integer total across weighted claimants.
LoadWave has to split whole virtual users — and whole iterations, and whole worker processes — across nodes whose capacities differ. Proportional division produces fractions, and naive rounding either loses or invents units. Every split in the system funnels through this package so that the same rule applies everywhere and the parts always add back up to the whole.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
Equal divides total across n claimants as evenly as possible, giving the remainder to the lowest indices.
func Largest ¶
Largest divides total across weights using the largest remainder method.
Each claimant first receives the floor of its exact proportional share; the units left over by rounding down are then handed out one at a time, to the claimants with the largest discarded fractions. Ties break toward the lower index, which keeps the result deterministic — important, because the coordinator and the node both compute apportionments and they must agree.
The returned slice always sums to exactly total, provided total is non-negative and at least one weight is positive. A total of zero, or an empty or all-zero weight set, yields all zeros.
Types ¶
This section is empty.