benchmark

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package benchmark runs `go test` benchmarks with profiling flags, materializes outputs under bench/<tag>/, drives pprof text/PNG and per-function extraction via collector, and discovers Benchmark* functions in the module.

Index

Constants

This section is empty.

Variables

View Source
var ExpectedFiles = map[string]string{
	"cpu":    "cpu.out",
	"memory": "memory.out",
	"mutex":  "mutex.out",
	"block":  "block.out",
}

ExpectedFiles maps profile names to expected pprof output filenames.

View Source
var ProfileFlags = map[string]string{
	"cpu":    "-cpuprofile=cpu.out",
	"memory": "-memprofile=memory.out",
	"mutex":  "-mutexprofile=mutex.out",
	"block":  "-blockprofile=block.out",
}

ProfileFlags maps profile names to go test profiling flags.

View Source
var SupportedProfiles = []string{"cpu", "memory", "mutex", "block"}

SupportedProfiles lists profile kinds supported by the benchmark pipeline.

Functions

func DiscoverBenchmarks added in v1.7.0

func DiscoverBenchmarks(scope string) ([]string, error)

DiscoverBenchmarks scans for functions matching:

func BenchmarkXxx(b *testing.B) { ... }

If scope is non-empty, search starts there; otherwise the module root is used.

func RunBenchmarks added in v1.8.0

func RunBenchmarks(benchmarks, profiles []string, tag string, count int, groupByPackage bool, lenientProfiles bool, skipPNG bool) error

RunBenchmarks validates flags, loads optional repo config, prepares bench layout, then runs the full pipeline.

Types

type ProfilePaths

type ProfilePaths struct {
	// Desired file path for specified profile
	ProfileTextFile string

	// Desired bin path for specified profile
	ProfileBinaryFile string

	// Desired benchmark directory for function data collection
	FunctionDirectory string
}

ProfilePaths holds paths for profile text, binary, and output directories.

Jump to

Keyboard shortcuts

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