Categorygithub.com/madlambda/benchcheck
modulepackage
0.0.0-20221012173426-292ac037f254
Repository: https://github.com/madlambda/benchcheck.git
Documentation: pkg.go.dev

# README

benchcheck

benchcheck runs benchmarks on two different versions of a Go module and compares statistics across them, failing on performance regressions.

This tool aims at being Go specific and wildly simple, leveraging standard Go benchmarks + benchstat, composing them to provide just a few extra features:

  • Given two module versions of a package, it automatically benchmarks and compares them
  • Given a threshold on the delta of performance loss, the check fails (useful for CI's)

And that is it, no more, no less.

Dependencies

  • git
  • go

Install

Just run:

go install github.com/madlambda/benchcheck/cmd/benchcheck@latest

Usage

For details just run:

benchcheck -help

By default all benchmarks are run with -benchmem, so you also have information on memory allocations.

Comparing performance between two versions of a Go module and just showing results on output (no check performed):

benchcheck cool.go.module v0.0.1 v0.0.2

Comparing performance between two versions of a Go module and failing on time regression:

benchcheck cool.go.module v0.0.1 v0.0.2 -time-delta +13.31%

Now doing the same but also checking for allocation regression:

benchcheck cool.go.module v0.0.1 v0.0.2 -alloc-delta +15% -allocs-delta +20%

You can also check if your code got faster and use the check to I don't know... Celebrate ? =P

benchcheck cool.go.module v0.0.1 v0.0.2 -time-delta -20%

# Packages

No description provided by the author

# Functions

GetModule will download a specific version of a module and return a directory where you can find the module code.
ParseChecker will parse the given string into a Check.
RunBench will run all benchmarks present at the given module return the benchmark results.
Stat compares two benchmark results providing a set of stats results.
StatModule will: - Download the specific versions of the given module.

# Constants

CheckerFmt represents the expected string format of a checker.

# Structs

BenchDiff is the result showing performance differences for a single benchmark function.
Checker performs checks on StatResult.
CmdError represents an error running a specific command.
Module represents a Go module.
StatResult is the full result showing performance differences between two benchmark runs (set of benchmark functions) for a specific metric, like time/op or speed.

# Type aliases

BenchResults represents a single Go benchmark run.