driver

package
v0.0.0-...-d10bd6d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: BSD-3-Clause Imports: 22 Imported by: 5

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

View Source
var (
	BenchTime time.Duration
	WorkDir   string
)

Functions

func BenchMem

func BenchMem() int

func InitSysStats

func InitSysStats(N uint64) sysStats

func LatencyNote

func LatencyNote(t time.Time)

func Main

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

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 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.

Types

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, and creates cpu/mem profiles.

func MakeResult

func MakeResult() Result

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL