Documentation ¶
Overview ¶
Package benchmark implements utilities to augment the standard Go testing.Benchmark functionality.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunTestMain ¶
RunTestMain runs the tests with enabling injection of benchmark stats. It returns an exit code to pass to os.Exit.
Types ¶
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Stats is a simple helper for gathering additional statistics like histogram during benchmarks. This is not thread safe.
func AddStats ¶
AddStats adds a new unnamed Stats instance to the current benchmark. You need to run benchmarks by calling RunTestMain() to inject the stats to the benchmark results. If numBuckets is not positive, the default value (16) will be used. Please note that this calls b.ResetTimer() since it may be blocked until the previous benchmark stats is printed out. So AddStats() should typically be called at the very beginning of each benchmark function.
func AddStatsWithName ¶
AddStatsWithName adds a new named Stats instance to the current benchmark. With this, you can add multiple stats in a single benchmark. You need to run benchmarks by calling RunTestMain() to inject the stats to the benchmark results. If numBuckets is not positive, the default value (16) will be used. Please note that this calls b.ResetTimer() since it may be blocked until the previous benchmark stats is printed out. So AddStatsWithName() should typically be called at the very beginning of each benchmark function.
func NewStats ¶
NewStats creates a new Stats instance. If numBuckets is not positive, the default value (16) will be used.