Documentation ¶
Overview ¶
Package units implements human-friendly representations of common units.
Index ¶
Constants ¶
const ( Runtime = "ns/op" DataRate = "MB/s" BytesAllocated = "B/op" Allocs = "allocs/op" )
Standard library testing package units.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ImprovementDirection ¶
type ImprovementDirection int
ImprovementDirection indicates which direction of change is considered better.
const ( ImprovementDirectionUnknown ImprovementDirection = 0 ImprovementDirectionLarger ImprovementDirection = 1 ImprovementDirectionSmaller ImprovementDirection = -1 )
Supported improvement direction values.
func ImprovementDirectionForUnit ¶
func ImprovementDirectionForUnit(unit string) ImprovementDirection
ImprovementDirectionForUnit returns the improvement direction for the supplied unit, if known.
func ImprovementDirectionString ¶
func ImprovementDirectionString(s string) (ImprovementDirection, error)
ImprovementDirectionString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func ImprovementDirectionValues ¶
func ImprovementDirectionValues() []ImprovementDirection
ImprovementDirectionValues returns all values of the enum
func (ImprovementDirection) IsAImprovementDirection ¶
func (i ImprovementDirection) IsAImprovementDirection() bool
IsAImprovementDirection returns "true" if the value is listed in the enum definition. "false" otherwise
func (ImprovementDirection) String ¶
func (i ImprovementDirection) String() string
type Quantity ¶
Quantity is a value in some unit.
func BytesBinary ¶
BytesBinary represents the given number of bytes with binary prefixes (multiples of 1024).
func (Quantity) FormatValue ¶
FormatValue formats the value with precision suitable for the unit.
func (Quantity) FormatValueWithPrecision ¶
FormatValueWithPrecision formats the value with up to prec significant digits.
func (Quantity) FormatWithPrecision ¶
FormatWithPrecision formats the quantity with up to prec significant digits.