benchreport

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package benchreport turns benchmark runs into a results file that records the host, build and method next to the numbers.

Index

Constants

View Source
const (
	GroupFailover   = "failover"
	GroupDeploy     = "deploy"
	GroupRollout    = "rollout"
	GroupThroughput = "throughput"
)

Scenario groups the dashboard and the compare view use.

View Source
const (
	DirectionBetter = "better"
	DirectionWorse  = "worse"
	DirectionSame   = "same"
)

Directions of a delta, judged by what a larger number means for the metric.

View Source
const SchemaVersion = 1

SchemaVersion changes when a field of the results file changes meaning.

Variables

This section is empty.

Functions

func Caveats

func Caveats(h Host, b Build, repeat int, noisyLoadRatio float64) []string

Caveats names the reasons these numbers must not be read as production numbers.

func Group

func Group(scenario string) string

Group names the section a scenario's numbers belong to.

func Load1

func Load1(ctx context.Context, p Probe) float64

Load1 returns the one minute load average, or -1 when the platform does not report it.

func Markdown

func Markdown(r Report) string

Markdown renders the report as a document that carries its own host, build and limits.

func Methodology

func Methodology() []string

Methodology lists how the numbers are taken, in the words published with them.

func ParseCPUInfoModel

func ParseCPUInfoModel(s string) string

ParseCPUInfoModel returns the first "model name" line of /proc/cpuinfo.

func ParseMemTotal

func ParseMemTotal(s string) uint64

ParseMemTotal returns MemTotal from /proc/meminfo in bytes.

func ParseOSRelease

func ParseOSRelease(s string) string

ParseOSRelease returns PRETTY_NAME from /etc/os-release.

func WriteJSON

func WriteJSON(path string, r Report) error

WriteJSON writes the report as indented JSON.

func WriteMarkdown

func WriteMarkdown(path string, r Report) error

WriteMarkdown writes Markdown(r) to path.

Types

type Build

type Build struct {
	Version string `json:"version"`
	Commit  string `json:"commit"`
	Dirty   bool   `json:"dirty"`
}

Build identifies the binary that produced the numbers.

type Comparison

type Comparison struct {
	Base      Side           `json:"base"`
	Head      Side           `json:"head"`
	Deltas    []Delta        `json:"deltas"`
	Status    []StatusChange `json:"status_changes"`
	Warnings  []string       `json:"warnings"`
	NoisePct  float64        `json:"noise_pct"`
	Statistic string         `json:"statistic"`
}

Comparison is the head report measured against the base report.

func Compare

func Compare(base, head Report, baseSide, headSide Side, noisePct float64) Comparison

Compare lines up every metric of two reports. A change smaller than noisePct percent is reported as the same.

type Delta

type Delta struct {
	Scenario  string   `json:"scenario"`
	Group     string   `json:"group"`
	Metric    string   `json:"metric"`
	Base      *float64 `json:"base"`
	Head      *float64 `json:"head"`
	Delta     *float64 `json:"delta"`
	DeltaPct  *float64 `json:"delta_pct"`
	Direction string   `json:"direction,omitempty"`
}

Delta is one metric on both sides. Each side is the median over that side's runs of the scenario.

type Docker

type Docker struct {
	Version  string `json:"version,omitempty"`
	OS       string `json:"os,omitempty"`
	MemBytes int64  `json:"mem_bytes,omitempty"`
}

Docker is what the Docker daemon reports about itself.

type Host

type Host struct {
	OS        string  `json:"os"`
	Arch      string  `json:"arch"`
	OSVersion string  `json:"os_version,omitempty"`
	Kernel    string  `json:"kernel,omitempty"`
	CPUModel  string  `json:"cpu_model,omitempty"`
	CPUs      int     `json:"cpus"`
	MemBytes  uint64  `json:"mem_bytes,omitempty"`
	Docker    Docker  `json:"docker"`
	LoadStart float64 `json:"load1_start"`
	LoadEnd   float64 `json:"load1_end"`
	Note      string  `json:"note,omitempty"`
}

Host describes the machine a run came from.

func DetectHost

func DetectHost(ctx context.Context, p Probe) Host

DetectHost fills a Host from p; fields a platform cannot report stay empty rather than guessed.

func (Host) Summary

func (h Host) Summary() string

Summary is a one line description of the host for table headers.

type Limit

type Limit struct {
	Question string `json:"question"`
	Status   string `json:"status"`
}

Limit states whether one question is answered by the results.

func Limits

func Limits(results []chaos.Result, repeat int) []Limit

Limits is the table of what the run measured and what it did not.

type Options

type Options struct {
	Build          Build
	Host           Host
	Repeat         int
	Now            time.Time
	NoisyLoadRatio float64
}

Options carries the inputs New cannot read from the results themselves.

type Probe

type Probe struct {
	GOOS     string
	GOARCH   string
	NumCPU   int
	ReadFile func(path string) ([]byte, error)
	Run      func(ctx context.Context, name string, args ...string) (string, error)
}

Probe is the set of system reads DetectHost uses, replaceable in tests.

func DefaultProbe

func DefaultProbe() Probe

DefaultProbe reads the real machine.

type Report

type Report struct {
	SchemaVersion int            `json:"schema_version"`
	GeneratedAt   time.Time      `json:"generated_at"`
	Build         Build          `json:"build"`
	Host          Host           `json:"host"`
	Repeat        int            `json:"repeat"`
	Methodology   []string       `json:"methodology"`
	Caveats       []string       `json:"caveats"`
	Results       []chaos.Result `json:"results"`
	Limits        []Limit        `json:"limits"`
}

Report is the results file: numbers plus everything needed to judge and repeat them.

func New

func New(results []chaos.Result, o Options) Report

New assembles a report, deriving the caveats and the limits table from what was actually run.

func Parse

func Parse(data []byte) (Report, error)

Parse decodes and validates an uploaded results file. Unknown fields are rejected so a mistyped file is not stored half understood.

func (Report) Tally

func (r Report) Tally() (passed, failed, skipped int)

Tally counts results by status.

func (Report) Validate

func (r Report) Validate() error

Validate rejects a report that would publish numbers without the facts needed to judge them.

type Side

type Side struct {
	ID          string `json:"id"`
	GeneratedAt string `json:"generated_at"`
	Version     string `json:"version"`
	Commit      string `json:"commit"`
	Dirty       bool   `json:"dirty"`
	Host        string `json:"host"`
	Runs        int    `json:"runs"`
}

Side identifies one report in a comparison.

type StatusChange

type StatusChange struct {
	Scenario string `json:"scenario"`
	Base     string `json:"base"`
	Head     string `json:"head"`
}

StatusChange lists a scenario whose outcome differs between the sides.

Jump to

Keyboard shortcuts

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