Skip to content

proposal: cmd/go: -benchformat option in go test #12826

@nodirt

Description

@nodirt

Background

Currently go test -bench . prints out benchmark results in a certain format, but there is no guarantee that this format will not change. Thus a tool that parses go test output may break if an incompatible change to the output format is made.

Also currently there is no good way to distinguish benchmark results from the rest of go test output, other than checking that a line starts with "Benchmark".

Proposal

  1. Add -benchformat flag to go test. Its value is a text/template template with BenchmarkResult input, similar to -f flag in go list.
  2. Add Proc to BenchmarkResult. It will have the value of runtime.GOMAXPROCS at the beginning of B.launch call.

Example:

$ go test -run=^$  -bench . \
  -benchformat "BENCHMARK STARTS HERE:{{.Name}}:{{.Proc}}:{{.T}}:{{.N}}:{{.Bytes}}"
PASS
BENCHMARK STARTS HERE:BenchmarkFoo:8:1s:10000:0
BENCHMARK STARTS HERE:BenchmarkBar:8:1s:10000:0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions