benchfmt

package
v0.0.0-...-f3e401e Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: BSD-3-Clause Imports: 8 Imported by: 17

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Labels

type Labels map[string]string

Labels is a set of key-value strings.

func (Labels) Copy

func (l Labels) Copy() Labels

Copy returns a new copy of the labels map, to protect against future modifications to labels.

func (Labels) Equal

func (l Labels) Equal(b Labels) bool

Equal reports whether l and b have the same keys and values.

func (Labels) Keys

func (l Labels) Keys() []string

Keys returns a sorted list of the keys in l.

func (Labels) String

func (l Labels) String() 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

func NewPrinter(w io.Writer) *Printer

NewPrinter constructs a BenchmarkPrinter writing to w.

func (*Printer) Print

func (p *Printer) Print(r *Result) error

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

func NewReader(r io.Reader) *Reader

NewReader creates a BenchmarkReader that reads from r.

func (*Reader) AddLabels

func (r *Reader) AddLabels(labels Labels)

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

func (r *Reader) Err() error

Err returns the error state of the reader.

func (*Reader) Next

func (r *Reader) Next() bool

Next returns the next benchmark result from the file. If there are no further results, it returns nil, io.EOF.

func (*Reader) Result

func (r *Reader) Result() *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

func (r *Result) SameLabels(b *Result) bool

SameLabels reports whether r and b have the same labels.

Jump to

Keyboard shortcuts

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