testbudget

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func CPU() time.Duration

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

func Of(d time.Duration) time.Duration

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL