microbench

package
v1.1.1-0...-f6905a7 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorLineUnrecognized = "the line format was unrecognized"
	ErrorLineMalformed    = "the format of the line is malformed"

	// GeneralBenchmark are results that fits with the generalBenchTypeRegExpr regular expression.
	GeneralBenchmark = microType("general")
)

Variables

This section is empty.

Functions

func Run

func Run(cfg Config) error

Run runs "go test bench" on the given package (pkg) and outputs the results to outputPath. Profiling files will be written to the current working directory.

Types

type BenchmarkId

type BenchmarkId struct {
	PkgName          string
	Name             string
	SubBenchmarkName string
}

BenchmarkId represents the identification of a microbenchmark.

func NewBenchmarkId

func NewBenchmarkId(pkgName string, name string, subBenchmarkName string) *BenchmarkId

NewBenchmarkId creates a new BenchmarkId.

type Comparison

type Comparison struct {
	BenchmarkId
	Right, Left Result

	// Difference between Right and Left.
	Diff Result
}

Comparison allows comparison of two Result that share the same BenchmarkId.

type ComparisonArray

type ComparisonArray []Comparison

func Compare

func Compare(client storage.SQLClient, right string, left string) (ComparisonArray, error)

Compare takes in 3 arguments, the database, and 2 SHAs. It reads from the database, the microbenchmark results for the 2 SHAs and compares them. The result is a comparison array.

func MergeDetails

func MergeDetails(rightMbd, leftMbd DetailsArray) (compareMbs ComparisonArray)

MergeDetails merges two DetailsArray into a single ComparisonArray.

func (ComparisonArray) Regression

func (microsMatrix ComparisonArray) Regression() (reason string)

Regression returns a string containing the reason of the regression of the given ComparisonArray, if no regression was evaluated, the reason will be an empty string. The format of a single benchmark regression's reason is like this:

"- {pkg name}/{benchmark name} decreased by {decrease percentage}%\n"

type Config

type Config struct {
	// RootDir is the root path from where micro benchmarks will
	// be executed.
	RootDir string

	// Package we want to microbenchmark.
	Package string

	// Output file on which to print the intermediate results.
	Output string

	// DatabaseConfig used to save results to SQL. If this field
	// is nil, saving results will be skipped and no error will
	// be returned.
	DatabaseConfig *psdb.Config
	// contains filtered or unexported fields
}

func (*Config) AddToCommand

func (mbc *Config) AddToCommand(cmd *cobra.Command)

type Details

type Details struct {
	BenchmarkId
	GitRef    string
	StartedAt string
	Result    Result
}

Details refers to a single microbenchmark.

func NewDetails

func NewDetails(benchmarkId BenchmarkId, gitRef string, startedAt string, result Result) *Details

NewDetails creates a new Details.

type DetailsArray

type DetailsArray []Details

func GetLatestResultsFor

func GetLatestResultsFor(name, subBenchmarkName string, count int, client storage.SQLClient) (mrs DetailsArray, err error)

GetLatestResultsFor will fetch and return a DetailsArray containing all the Details linked to latest runs of the given benchmark name.

func GetResultsForGitRef

func GetResultsForGitRef(ref string, client storage.SQLClient) (mrs DetailsArray, err error)

GetResultsForGitRef will fetch and return a DetailsArray containing all the Details linked to the given git commit SHA.

func (DetailsArray) ReduceSimpleMedianByGitRef

func (mbd DetailsArray) ReduceSimpleMedianByGitRef() (reduceMbd DetailsArray)

ReduceSimpleMedianByGitRef reduces a DetailsArray by merging all Details with the same git ref into a single one. The results of each Details correspond to the median of the merged elements.

func (DetailsArray) ReduceSimpleMedianByName

func (mbd DetailsArray) ReduceSimpleMedianByName() (reduceMbd DetailsArray)

ReduceSimpleMedianByName reduces a DetailsArray by merging all Details with the same benchmark name into a single one. The results of each Details correspond to the median of the merged elements.

func (DetailsArray) SortByDate

func (mbd DetailsArray) SortByDate()

SortByDate will sort the given DetailsArray by ascending date

type Result

type Result struct {
	Ops         float64
	NSPerOp     float64
	MBPerSec    float64
	BytesPerOp  float64
	AllocsPerOp float64
}

Result contains all the metrics measured by a microbenchmark.

func NewResult

func NewResult(ops, NSPerOp, MBPerSec, BytesPerOp, AllocsPerOp float64) *Result

NewResult creates a new Result.

func (Result) AllocsPerOpStr

func (r Result) AllocsPerOpStr() string

func (Result) BytesPerOpStr

func (r Result) BytesPerOpStr() string

func (Result) MBPerSecStr

func (r Result) MBPerSecStr() string

func (Result) NSPerOpStr

func (r Result) NSPerOpStr() string

func (Result) NSPerOpToDurationStr

func (r Result) NSPerOpToDurationStr() string

func (Result) OpsStr

func (r Result) OpsStr() string

Jump to

Keyboard shortcuts

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