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 ¶
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.