package benchfmt
import "golang.org/x/perf/storage/benchfmt"
Package benchfmt provides readers and writers for the Go benchmark format.
The format is documented at https://golang.org/design/14313-benchmark-format
This package only parses file configuration lines, not benchmark result lines. Parsing the result lines is left to the caller.
Deprecated: See the golang.org/x/perf/benchfmt package, which implements readers and writers for the full Go benchmark format. It is also higher performance.
Index ¶
- type Labels
- func (l Labels) Copy() Labels
- func (l Labels) Equal(b Labels) bool
- func (l Labels) Keys() []string
- func (l Labels) String() string
- type Printer
- type Reader
- func NewReader(r io.Reader) *Reader
- func (r *Reader) AddLabels(labels Labels)
- func (r *Reader) Err() error
- func (r *Reader) Next() bool
- func (r *Reader) Result() *Result
- type Result
Types ¶
type Labels ¶
Labels is a set of key-value strings.
func (Labels) Copy ¶
Copy returns a new copy of the labels map, to protect against future modifications to labels.
func (Labels) Equal ¶
Equal reports whether l and b have the same keys and values.
func (Labels) Keys ¶
Keys returns a sorted list of the keys in l.
func (Labels) String ¶
String returns the labels formatted as a comma-separated list enclosed in braces.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
A Printer prints a sequence of benchmark results.
func NewPrinter ¶
NewPrinter constructs a BenchmarkPrinter writing to w.
func (*Printer) Print ¶
Print writes the lines necessary to recreate r.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads benchmark results from an io.Reader. Use Next to advance through the results.
br := benchfmt.NewReader(r) for br.Next() { res := br.Result() ... } err = br.Err() // get any error encountered during iteration ...
func NewReader ¶
NewReader creates a BenchmarkReader that reads from r.
func (*Reader) AddLabels ¶
AddLabels adds additional labels as if they had been read from the header of a file. It must be called before the first call to r.Next.
func (*Reader) Err ¶
Err returns the error state of the reader.
func (*Reader) Next ¶
Next returns the next benchmark result from the file. If there are no further results, it returns nil, io.EOF.
func (*Reader) Result ¶
Result returns the most recent result generated by a call to Next.
type Result ¶
type Result struct { // Labels is the set of persistent labels that apply to the result. // Labels must not be modified. Labels Labels // NameLabels is the set of ephemeral labels that were parsed // from the benchmark name/line. // NameLabels must not be modified. NameLabels Labels // LineNum is the line number on which the result was found LineNum int // Content is the verbatim input line of the benchmark file, beginning with the string "Benchmark". Content string }
Result represents a single line from a benchmark file. All information about that line is self-contained in the Result. A Result is immutable once created.
func (*Result) SameLabels ¶
SameLabels reports whether r and b have the same labels.
Source Files ¶
benchfmt.go
- Version
- v0.0.0-20250214215153-c95ad7d5b636 (latest)
- Published
- Feb 14, 2025
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 1 week ago –
Tools for package owners.