Documentation ¶
Overview ¶
Package benchutil contains utilities used for benchmarking and
Index ¶
- func Dot(done chan struct{})
- func NewSeed() int64
- func RandBool() bool
- func RandBytes(l uint32) []byte
- func RandString(l uint32) string
- type Bench
- type Benches
- func (b *Benches) AllocsOpString(v Bench) string
- func (b *Benches) Append(benches ...Bench)
- func (b *Benches) BytesOpString(v Bench) string
- func (b *Benches) DetailedSystemInfo() (string, error)
- func (b *Benches) IncludeDetailedSystemInfo(v bool)
- func (b *Benches) IncludeOpsColumnDesc(v bool)
- func (b *Benches) IncludeSystemInfo(v bool)
- func (b *Benches) NameSections(v bool)
- func (b *Benches) NsOpString(v Bench) string
- func (b *Benches) OpsString(v Bench) string
- func (b *Benches) SectionHeaders(v bool)
- func (b *Benches) SectionPerGroup(v bool)
- func (h *Benches) SetAllocsOpColumnHeader(s string)
- func (h *Benches) SetBytesOpColumnHeader(s string)
- func (b *Benches) SetColumnPadding(i int)
- func (h *Benches) SetDescColumnHeader(s string)
- func (h *Benches) SetGroupColumnHeader(s string)
- func (h *Benches) SetNameColumnHeader(s string)
- func (h *Benches) SetNoteColumnHeader(s string)
- func (h *Benches) SetNsOpColumnHeader(s string)
- func (h *Benches) SetOpsColumnHeader(s string)
- func (h *Benches) SetSubGroupColumnHeader(s string)
- func (b *Benches) SystemInfo() (string, error)
- type Benchmarker
- type CSVBench
- func (b *CSVBench) Out() error
- func (h *CSVBench) SetAllocsOpColumnHeader(s string)
- func (h *CSVBench) SetBytesOpColumnHeader(s string)
- func (h *CSVBench) SetDescColumnHeader(s string)
- func (h *CSVBench) SetGroupColumnHeader(s string)
- func (h *CSVBench) SetNameColumnHeader(s string)
- func (h *CSVBench) SetNoteColumnHeader(s string)
- func (h *CSVBench) SetNsOpColumnHeader(s string)
- func (h *CSVBench) SetOpsColumnHeader(s string)
- func (h *CSVBench) SetSubGroupColumnHeader(s string)
- type MDBench
- func (b *MDBench) Out() error
- func (b *MDBench) SectionName(s string) string
- func (h *MDBench) SetAllocsOpColumnHeader(s string)
- func (h *MDBench) SetBytesOpColumnHeader(s string)
- func (h *MDBench) SetDescColumnHeader(s string)
- func (h *MDBench) SetGroupColumnHeader(s string)
- func (h *MDBench) SetNameColumnHeader(s string)
- func (h *MDBench) SetNoteColumnHeader(s string)
- func (h *MDBench) SetNsOpColumnHeader(s string)
- func (h *MDBench) SetOpsColumnHeader(s string)
- func (h *MDBench) SetSubGroupColumnHeader(s string)
- type Result
- type StringBench
- func (b *StringBench) BenchString(i int) string
- func (b *StringBench) Out() error
- func (h *StringBench) SetAllocsOpColumnHeader(s string)
- func (h *StringBench) SetBytesOpColumnHeader(s string)
- func (h *StringBench) SetDescColumnHeader(s string)
- func (h *StringBench) SetGroupColumnHeader(s string)
- func (h *StringBench) SetNameColumnHeader(s string)
- func (h *StringBench) SetNoteColumnHeader(s string)
- func (h *StringBench) SetNsOpColumnHeader(s string)
- func (h *StringBench) SetOpsColumnHeader(s string)
- func (h *StringBench) SetSubGroupColumnHeader(s string)
- func (b *StringBench) WriteHeader()
- func (b *StringBench) WriteResults()
- func (b *StringBench) WriteSeparatorLine()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RandBytes ¶
RandBytes returns a randomly generated []byte of length l. The values of these bytes are restricted to the ASCII alphanum range; that doesn't matter for the purposes of these benchmarks.
func RandString ¶
RandString returns a randomly generated string of length l.
Types ¶
type Bench ¶
type Bench struct { Group string // the Grouping of benchmarks this bench belongs to. SubGroup string // the Sub-Group this bench belongs to; mainly for additional sort options. Name string // Name of the bench. Desc string // Description of the bench; optional. Note string // Additional note about the bench; optional. Iterations int // number of test iterations; default 1 Result // A map of Result keyed by something. }
Bench holds information about a benchmark. If there is a value for Group, the output will have a break between the groups.
type Benches ¶
type Benches struct { Name string // Name of the set; optional. Desc string // Description of the collection of benchmarks; optional. Note string // Additional notes about the set; optional. Benchmarks []Bench // The benchmark results // contains filtered or unexported fields }
Benches is a collection of benchmark informtion and their results.
func (*Benches) AllocsOpString ¶
AllocsOpString returns the allocations per operation as a formatted string.
func (*Benches) BytesOpString ¶
BytesOpString returns the bytes allocated for each operation as a formatted string.
func (*Benches) DetailedSystemInfo ¶
DetailedSystemInfo generates the System Information string, including information about every CPU core on the system.
func (*Benches) IncludeDetailedSystemInfo ¶
DetailedSystemInfoOutput: if true, detailed system info will be included in the benchmarker's output. If both IncludeSystemInfo and IncludeDetailedSystemInfo are set to true, the detailed system info will be included.
func (*Benches) IncludeOpsColumnDesc ¶
IncludeOpsColumnDesc: if true, the ops information will be included in each ops column's result.
func (*Benches) IncludeSystemInfo ¶
IncludeSystemInfo: if true, basic system info will be included in the benchmarker's output. If both IncludeSystemInfo and IncludeDetailedSystemInfo are set to true, the detailed system info will be included.
func (*Benches) NameSections ¶
Sets the nameSections bool. Txt output ignores this.
func (*Benches) NsOpString ¶
NsOpString returns the nanoseconds each operation took as a formatted string.
func (*Benches) OpsString ¶
OpsString returns the operations performed by the benchmark as a formatted string.
func (*Benches) SectionHeaders ¶
Sets the sectionHeaders bool. Txt output ignores this.
func (*Benches) SectionPerGroup ¶
Sets the sectionPerGroup bool
func (*Benches) SetAllocsOpColumnHeader ¶
func (h *Benches) SetAllocsOpColumnHeader(s string)
SetAllocsOpColumnHeader sets the AllocsOp column header; default is 'Allocs/Op'. This only applies when AllocsOp is part of the output.
func (*Benches) SetBytesOpColumnHeader ¶
func (h *Benches) SetBytesOpColumnHeader(s string)
SetBytesOpColumnHeader sets the BytesOp column header; default is 'B/Op'. This only applies when BytesOp is part of the output.
func (*Benches) SetColumnPadding ¶
Sets the number of spaces between columns; default is 2.
func (*Benches) SetDescColumnHeader ¶
func (h *Benches) SetDescColumnHeader(s string)
SetDescColumnHeader sets the Desc column header; default is 'Desc'. This only applies when Desc is part of the output.
func (*Benches) SetGroupColumnHeader ¶
func (h *Benches) SetGroupColumnHeader(s string)
SetGroupColumnHeader sets the Group column header; default is 'Group'. This only applies when Group is part of the output.
func (*Benches) SetNameColumnHeader ¶
func (h *Benches) SetNameColumnHeader(s string)
SetNameColumnHeader sets the Name column header; default is 'Name'.
func (*Benches) SetNoteColumnHeader ¶
func (h *Benches) SetNoteColumnHeader(s string)
SetNoteColumnHeader sets the Note column header; default is 'Note'. This only applies when Note is part of the output.
func (*Benches) SetNsOpColumnHeader ¶
func (h *Benches) SetNsOpColumnHeader(s string)
SetNsOpColumnHeader sets the NsOp column header; default is 'ns/Op'. This only applies when NsOp is part of the output.
func (*Benches) SetOpsColumnHeader ¶
func (h *Benches) SetOpsColumnHeader(s string)
SetOpsColumnHeader sets the Ops column header; default is 'Ops'. This only applies when Ops is part of the output.
func (*Benches) SetSubGroupColumnHeader ¶
func (h *Benches) SetSubGroupColumnHeader(s string)
SetSubGroupColumnHeader sets the SubGroup column header; default is 'Sub-Group'. This only applies when SubGroup is part of the output.
func (*Benches) SystemInfo ¶
SystemInfo generates a System Information string.
type Benchmarker ¶
type Benchmarker interface { Append(...Bench) Out() error IncludeOpsColumnDesc(bool) IncludeSystemInfo(bool) IncludeDetailedSystemInfo(bool) SystemInfo() (string, error) DetailedSystemInfo() (string, error) SetGroupColumnHeader(s string) SetSubGroupColumnHeader(s string) SetNameColumnHeader(s string) SetDescColumnHeader(s string) SetOpsColumnHeader(s string) SetNsOpColumnHeader(s string) SetBytesOpColumnHeader(s string) SetAllocsOpColumnHeader(s string) SetNoteColumnHeader(s string) SetColumnPadding(i int) SectionPerGroup(bool) SectionHeaders(bool) NameSections(bool) }
Benchmarker defines common behavior for a Benchmark output harness; format specific methods may be
type CSVBench ¶
type CSVBench struct { Benches // contains filtered or unexported fields }
CSVBench Benches is a collection of benchmark informtion and their results. The output is written as CSV to the writer. The Name, Desc, and Note fields are ignored
func NewCSVBench ¶
func (*CSVBench) SetAllocsOpColumnHeader ¶
func (h *CSVBench) SetAllocsOpColumnHeader(s string)
SetAllocsOpColumnHeader sets the AllocsOp column header; default is 'Allocs/Op'. This only applies when AllocsOp is part of the output.
func (*CSVBench) SetBytesOpColumnHeader ¶
func (h *CSVBench) SetBytesOpColumnHeader(s string)
SetBytesOpColumnHeader sets the BytesOp column header; default is 'B/Op'. This only applies when BytesOp is part of the output.
func (*CSVBench) SetDescColumnHeader ¶
func (h *CSVBench) SetDescColumnHeader(s string)
SetDescColumnHeader sets the Desc column header; default is 'Desc'. This only applies when Desc is part of the output.
func (*CSVBench) SetGroupColumnHeader ¶
func (h *CSVBench) SetGroupColumnHeader(s string)
SetGroupColumnHeader sets the Group column header; default is 'Group'. This only applies when Group is part of the output.
func (*CSVBench) SetNameColumnHeader ¶
func (h *CSVBench) SetNameColumnHeader(s string)
SetNameColumnHeader sets the Name column header; default is 'Name'.
func (*CSVBench) SetNoteColumnHeader ¶
func (h *CSVBench) SetNoteColumnHeader(s string)
SetNoteColumnHeader sets the Note column header; default is 'Note'. This only applies when Note is part of the output.
func (*CSVBench) SetNsOpColumnHeader ¶
func (h *CSVBench) SetNsOpColumnHeader(s string)
SetNsOpColumnHeader sets the NsOp column header; default is 'ns/Op'. This only applies when NsOp is part of the output.
func (*CSVBench) SetOpsColumnHeader ¶
func (h *CSVBench) SetOpsColumnHeader(s string)
SetOpsColumnHeader sets the Ops column header; default is 'Ops'. This only applies when Ops is part of the output.
func (*CSVBench) SetSubGroupColumnHeader ¶
func (h *CSVBench) SetSubGroupColumnHeader(s string)
SetSubGroupColumnHeader sets the SubGroup column header; default is 'Sub-Group'. This only applies when SubGroup is part of the output.
type MDBench ¶
type MDBench struct { Benches SectionHeaderHash string // the markdown header hash for section names, when applicable // contains filtered or unexported fields }
MDBench Benches is a collection of benchmark informtion and their results. The output is written as Markdown to the writer, with the benchmark results formatted as a table.
func NewMDBench ¶
func (*MDBench) SectionName ¶
SectionName generates the section name; if applicable.
func (*MDBench) SetAllocsOpColumnHeader ¶
func (h *MDBench) SetAllocsOpColumnHeader(s string)
SetAllocsOpColumnHeader sets the AllocsOp column header; default is 'Allocs/Op'. This only applies when AllocsOp is part of the output.
func (*MDBench) SetBytesOpColumnHeader ¶
func (h *MDBench) SetBytesOpColumnHeader(s string)
SetBytesOpColumnHeader sets the BytesOp column header; default is 'B/Op'. This only applies when BytesOp is part of the output.
func (*MDBench) SetDescColumnHeader ¶
func (h *MDBench) SetDescColumnHeader(s string)
SetDescColumnHeader sets the Desc column header; default is 'Desc'. This only applies when Desc is part of the output.
func (*MDBench) SetGroupColumnHeader ¶
func (h *MDBench) SetGroupColumnHeader(s string)
SetGroupColumnHeader sets the Group column header; default is 'Group'. This only applies when Group is part of the output.
func (*MDBench) SetNameColumnHeader ¶
func (h *MDBench) SetNameColumnHeader(s string)
SetNameColumnHeader sets the Name column header; default is 'Name'.
func (*MDBench) SetNoteColumnHeader ¶
func (h *MDBench) SetNoteColumnHeader(s string)
SetNoteColumnHeader sets the Note column header; default is 'Note'. This only applies when Note is part of the output.
func (*MDBench) SetNsOpColumnHeader ¶
func (h *MDBench) SetNsOpColumnHeader(s string)
SetNsOpColumnHeader sets the NsOp column header; default is 'ns/Op'. This only applies when NsOp is part of the output.
func (*MDBench) SetOpsColumnHeader ¶
func (h *MDBench) SetOpsColumnHeader(s string)
SetOpsColumnHeader sets the Ops column header; default is 'Ops'. This only applies when Ops is part of the output.
func (*MDBench) SetSubGroupColumnHeader ¶
func (h *MDBench) SetSubGroupColumnHeader(s string)
SetSubGroupColumnHeader sets the SubGroup column header; default is 'Sub-Group'. This only applies when SubGroup is part of the output.
type Result ¶
type Result struct { Ops int64 // the number of operations performed NsOp int64 // The amount of time, in Nanoseconds, per Op. BytesOp int64 // The number of bytes allocated per Op. AllocsOp int64 // The number of Allocations per Op. }
Result holds information about a benchmark's results.
func ResultFromBenchmarkResult ¶
func ResultFromBenchmarkResult(br testing.BenchmarkResult) Result
ResultFromBenchmarkResult creates a Result{} from a testing.BenchmarkResult.
type StringBench ¶
type StringBench struct { Benches // contains filtered or unexported fields }
StringBench generates string output from the benchmarks.
func NewStringBench ¶
func NewStringBench(w io.Writer) *StringBench
func (*StringBench) BenchString ¶
func (b *StringBench) BenchString(i int) string
BenchString generates the Ops, ns/Ops, B/Ops, and Allocs/Op string for a given benchmark result.
func (*StringBench) SetAllocsOpColumnHeader ¶
func (h *StringBench) SetAllocsOpColumnHeader(s string)
SetAllocsOpColumnHeader sets the AllocsOp column header; default is 'Allocs/Op'. This only applies when AllocsOp is part of the output.
func (*StringBench) SetBytesOpColumnHeader ¶
func (h *StringBench) SetBytesOpColumnHeader(s string)
SetBytesOpColumnHeader sets the BytesOp column header; default is 'B/Op'. This only applies when BytesOp is part of the output.
func (*StringBench) SetDescColumnHeader ¶
func (h *StringBench) SetDescColumnHeader(s string)
SetDescColumnHeader sets the Desc column header; default is 'Desc'. This only applies when Desc is part of the output.
func (*StringBench) SetGroupColumnHeader ¶
func (h *StringBench) SetGroupColumnHeader(s string)
SetGroupColumnHeader sets the Group column header; default is 'Group'. This only applies when Group is part of the output.
func (*StringBench) SetNameColumnHeader ¶
func (h *StringBench) SetNameColumnHeader(s string)
SetNameColumnHeader sets the Name column header; default is 'Name'.
func (*StringBench) SetNoteColumnHeader ¶
func (h *StringBench) SetNoteColumnHeader(s string)
SetNoteColumnHeader sets the Note column header; default is 'Note'. This only applies when Note is part of the output.
func (*StringBench) SetNsOpColumnHeader ¶
func (h *StringBench) SetNsOpColumnHeader(s string)
SetNsOpColumnHeader sets the NsOp column header; default is 'ns/Op'. This only applies when NsOp is part of the output.
func (*StringBench) SetOpsColumnHeader ¶
func (h *StringBench) SetOpsColumnHeader(s string)
SetOpsColumnHeader sets the Ops column header; default is 'Ops'. This only applies when Ops is part of the output.
func (*StringBench) SetSubGroupColumnHeader ¶
func (h *StringBench) SetSubGroupColumnHeader(s string)
SetSubGroupColumnHeader sets the SubGroup column header; default is 'Sub-Group'. This only applies when SubGroup is part of the output.
func (*StringBench) WriteHeader ¶
func (b *StringBench) WriteHeader()
WriteHeader writes the table header to the writer.
func (*StringBench) WriteResults ¶
func (b *StringBench) WriteResults()
WriteResults writes the benchmark results to the writer.
func (*StringBench) WriteSeparatorLine ¶
func (b *StringBench) WriteSeparatorLine()
WriteSeparatorLine writes a line consisting of dashes to the writer.