report

package
v0.0.0-...-e209eb6 Latest Latest
Warning

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

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

Documentation

Overview

Package report generates formatted output from bench evaluation results.

Every reporter implements the Reporter interface:

type Reporter interface {
    Name() string
    Generate(w io.Writer, result *bench.RunResult) error
}

Available Formats

  • JSON — canonical Bench JSON with $schema and version fields
  • Markdown — GitHub-flavored Markdown tables
  • Table — ASCII table for terminal display
  • CSV — comma-separated values for spreadsheet import
  • JUnit — JUnit XML for CI integration
  • VegaLite — Vega-Lite JSON specifications for interactive charts
  • HTML — self-contained HTML report with embedded charts

Usage

r := report.JSON()
var buf bytes.Buffer
if err := r.Generate(&buf, result); err != nil {
    log.Fatal(err)
}
fmt.Println(buf.String())

Multiple reporters can be used on the same result:

reporters := []report.Reporter{
    report.JSON(),
    report.Markdown(),
    report.Table(),
}
for _, r := range reporters {
    f, _ := os.Create("report." + r.Name())
    r.Generate(f, result)
    f.Close()
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VegaLiteSpecs

func VegaLiteSpecs(result *bench.RunResult) map[string]any

VegaLiteSpecs generates individual Vega-Lite specs from run results. Returns a map of filename → JSON spec.

Types

type JUnitOption

type JUnitOption func(*junitReporter)

JUnitOption configures the JUnit reporter.

func WithTargets

func WithTargets(targets map[string]float64) JUnitOption

WithTargets sets metric targets. Each metric with a matching entry becomes a test case that passes if the metric value >= the target.

type Reporter

type Reporter interface {
	// Name returns the reporter's format name.
	Name() string
	// Generate writes the formatted report to w.
	Generate(w io.Writer, result *bench.RunResult) error
}

Reporter generates formatted output from benchmark results.

func CSV

func CSV() Reporter

CSV returns a reporter that outputs flat tabular CSV with one row per metric.

func HTML

func HTML() Reporter

HTML creates a reporter that outputs a self-contained HTML report. The report embeds Vega-Lite specs and loads Vega-Embed from CDN.

func JSON

func JSON() Reporter

JSON returns a reporter that outputs the canonical Bench JSON format.

func JUnit

func JUnit(opts ...JUnitOption) Reporter

JUnit returns a reporter that outputs JUnit XML for CI/CD integration. Metrics with configured targets become test cases: pass if value >= target.

func Markdown

func Markdown() Reporter

Markdown returns a reporter that outputs GitHub-flavored Markdown tables.

func Table

func Table() Reporter

Table returns a reporter that outputs ASCII tables for terminal display.

func VegaLite

func VegaLite() Reporter

VegaLite creates a reporter that outputs Vega-Lite visualization specs. It generates multiple spec files as a JSON object { "filename": spec, ... }.

Jump to

Keyboard shortcuts

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