Documentation
¶
Overview ¶
Package testbudget scales time limits in tests by the speed of the machine at test time, and measures compute-bound work in CPU time (CPU), so complexity-regression tests (whose broken behavior costs orders of magnitude more than the limit) do not fail spuriously on a loaded machine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CPU ¶
CPU returns the CPU time (user + system) the process has used so far. Unlike wall-clock time, it does not grow while other processes hold the CPU, so a limit on compute-bound work holds on a loaded machine; time such work as `start := testbudget.CPU(); …; testbudget.CPU() - start`, with no other test of the package running in parallel.
func Of ¶
Of returns d scaled by how much slower than the reference the machine is right now (never less than d itself), and by raceFactor in a race-detector build. It calibrates on every call (about 10 ms), so call it right after the timed work: the load then is the load the work ran under, not that of a quieter moment earlier in the run.
Types ¶
This section is empty.