compare

package
v6.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package compare calculates explicit, dimension-preserving comparisons of saved runs.

Index

Constants

View Source
const (
	Schema  = 1
	MaxRuns = 8
	MinRuns = 2
)

Variables

View Source
var (
	ErrSelection = errors.New("comparison requires 2–8 distinct history IDs and a selected reference")
)

Functions

func Change

func Change(value, reference json.Number) (delta, percent *json.Number, rounded bool)

Change calculates exact decimal subtraction and a bounded percentage representation.

func WriteText

func WriteText(output io.Writer, result *Result) error

WriteText renders the same values and reasons exposed by Result JSON.

Types

type Cell

type Cell struct {
	Value         *json.Number `json:"value"`
	Reason        string       `json:"reason,omitempty"`
	Delta         *json.Number `json:"delta"`
	Percent       *json.Number `json:"percent"`
	PercentReason string       `json:"percent_reason,omitempty"`
	Rounded       bool         `json:"rounded,omitempty"`
	DeltaReason   string       `json:"delta_reason,omitempty"`
}

Cell distinguishes absent/incompatible data from a recorded zero.

type Difference

type Difference struct {
	Path   string  `json:"path"`
	Values []Value `json:"values"`
}

Difference retains missing values separately from explicit nulls.

type Input

type Input struct {
	ID   string
	Data json.RawMessage
}

Input retains the history identity separately from reusable run IDs.

type Result

type Result struct {
	Schema      int          `json:"schema"`
	Kind        string       `json:"kind"`
	Reference   string       `json:"reference"`
	Runs        []Run        `json:"runs"`
	Differences []Difference `json:"differences"`
	Metrics     []Row        `json:"metrics"`
	Warnings    []string     `json:"warnings"`
}

Result is shared by machine, terminal, and HTML presentations.

func Build

func Build(inputs []Input, reference string) (*Result, error)

Build compares source documents without changing their recording semantics.

func Load

func Load(history *report.History, ids []string, reference string) (*Result, error)

Load resolves stable history IDs and retains input order for the default reference.

type Row

type Row struct {
	Name        string         `json:"name"`
	Type        string         `json:"type"`
	Unit        string         `json:"unit"`
	Scope       string         `json:"scope"`
	Attributes  map[string]any `json:"attributes,omitempty"`
	Statistic   string         `json:"statistic"`
	ValueUnit   string         `json:"value_unit"`
	Approximate bool           `json:"approximate,omitempty"`
	Bounds      []json.Number  `json:"bounds,omitempty"`
	Cells       []Cell         `json:"cells"`
}

Row is one statistic with an exact recorded type, unit, and dimension scope.

type Run

type Run struct {
	ID       string          `json:"history_id"`
	Workload string          `json:"workload"`
	Status   string          `json:"status"`
	Source   json.RawMessage `json:"source"`
	Warnings []string        `json:"warnings"`
	// contains filtered or unexported fields
}

Run preserves source JSON, including unknown fields and exact source numbers.

type Value

type Value struct {
	Present bool `json:"present"`
	Data    any  `json:"data"`
}

Jump to

Keyboard shortcuts

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