v.io: v.io/x/ref/test/benchmark Index | Files

package benchmark

import "v.io/x/ref/test/benchmark"

Package benchmark implements utilities to augment the standard Go testing.Benchmark functionality.

Index

Package Files

stats.go util.go

func RunTestMain Uses

func RunTestMain(m *testing.M) int

RunTestMain runs the tests with enabling injection of benchmark stats. It returns an exit code to pass to os.Exit.

type Stats Uses

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 Uses

func AddStats(b *testing.B, numBuckets int) *Stats

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 Uses

func AddStatsWithName(b *testing.B, name string, numBuckets int) *Stats

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 Uses

func NewStats(numBuckets int) *Stats

NewStats creates a new Stats instance. If numBuckets is not positive, the default value (16) will be used.

func (*Stats) Add Uses

func (stats *Stats) Add(d time.Duration)

Add adds an elapsed time per operation to the stats.

func (*Stats) Clear Uses

func (stats *Stats) Clear()

Clear resets the stats, removing all values.

func (*Stats) Print Uses

func (stats *Stats) Print(w io.Writer)

Print writes textual output of the Stats.

func (*Stats) String Uses

func (stats *Stats) String() string

String returns the textual output of the Stats as string.

Package benchmark imports 13 packages (graph) and is imported by 10 packages. Updated 2020-06-09. Refresh now. Tools for package owners.