benchmarks: golang.org/x/benchmarks/driver Index | Files

package driver

import "golang.org/x/benchmarks/driver"

Driver contains common benchmarking logic shared between benchmarks. It defines the main function which calls one of the benchmarks registered with Register function. When a benchmark is invoked it has 2 choices:

1. Do whatever it wants, fill and return Result object.
2. Call Benchmark helper function and provide benchmarking function
func(N uint64), similar to standard testing benchmarks. The rest is handled
by the driver.

Index

Package Files

driver.go driver_go12.go driver_go15.go driver_linux.go driver_unix.go

Variables

var (
    BenchNum  int
    BenchMem  int
    BenchTime time.Duration
    WorkDir   string
)

func InitSysStats

func InitSysStats(N uint64) sysStats

func LatencyNote

func LatencyNote(t time.Time)

func Main

func Main()

func Parallel

func Parallel(N uint64, P int, f func())

Parallel is a public helper function that runs f N times in P*GOMAXPROCS goroutines.

func Register

func Register(name string, f func() Result)

func RunAndCollectSysStats

func RunAndCollectSysStats(cmd *exec.Cmd, res *Result, N uint64, prefix string) (string, error)

func RunUnderProfiler

func RunUnderProfiler(args ...string) (string, string)

Runs the cmd under perf. Returns filename of the profile. Any errors are ignored.

func Size

func Size(file string) string

Size runs size command on the file. Returns filename with output. Any errors are ignored.

type Result

type Result struct {
    N        uint64        // number of iterations
    Duration time.Duration // total run duration
    RunTime  uint64        // ns/op
    Metrics  map[string]uint64
    Files    map[string]string
}

Result contains all the interesting data about benchmark execution.

func Benchmark

func Benchmark(f func(uint64)) Result

Benchmark runs f several times, collects stats, chooses the best run and creates cpu/mem profiles.

func MakeResult

func MakeResult() Result

Package driver imports 22 packages (graph) and is imported by 5 packages. Updated 2 months ago. Refresh now. Tools for package owners.