benchmarks: Index | Files

package driver

import ""

Package driver provides common benchmarking logic shared between benchmarks.

A benchmark should call Main with a benchmark function. The benchmark function can do one of two things when invoked:

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.


Package Files

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


var (
    BenchTime time.Duration
    WorkDir   string

func BenchMem Uses

func BenchMem() int

func InitSysStats Uses

func InitSysStats(N uint64) sysStats

func LatencyNote Uses

func LatencyNote(t time.Time)

func Main Uses

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

func Parallel Uses

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

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

func RunAndCollectSysStats Uses

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

func RunUnderProfiler Uses

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

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

func Size Uses

func Size(file string) string

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

type Result Uses

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 Uses

func Benchmark(f func(uint64)) Result

Benchmark runs f several times, collects stats, and creates cpu/mem profiles.

func MakeResult Uses

func MakeResult() Result

Package driver imports 23 packages (graph) and is imported by 8 packages. Updated 2019-11-29. Refresh now. Tools for package owners.