Documentation
¶
Overview ¶
Package loadavg reads the host's 1-minute load average and waits for it to drop, so that a benchmark is not measured on a busy machine.
Linux reads /proc/loadavg (proc(5)). Darwin reads sysctl vm.loadavg, a struct loadavg { fixpt_t ldavg[3]; long fscale; } (xnu sys/resource.h). Every other platform gets a clear error, never a zero.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBusy = errors.New("load average above the limit")
ErrBusy is wrapped by the error Wait returns when the load stayed above the limit for the whole timeout.
Functions ¶
func Wait ¶
func Wait(ctx context.Context, max float64, timeout, poll time.Duration, onWait func(float64)) (float64, error)
Wait returns the current 1-minute load once it is at most max. With a zero timeout it checks once. Otherwise it polls every poll until timeout has elapsed, then gives up with an error wrapping ErrBusy. onWait, when not nil, is called with each reading that is too high before sleeping.
Types ¶
This section is empty.