Documentation ¶
Overview ¶
Package prettify provides a set of functions to format benchmark results prettily.
Index ¶
- func FormatAllocsPerOp(l *parse.Benchmark) string
- func FormatBytesAllocPerOp(l *parse.Benchmark) string
- func FormatIterations(iter int) string
- func FormatMegaBytesPerSecond(l *parse.Benchmark) string
- type BenchOutputGroup
- func (g *BenchOutputGroup) AddLine(line *parse.Benchmark)
- func (g *BenchOutputGroup) ColumnNames() []string
- func (g *BenchOutputGroup) FormatTimeUnit(ns float64) string
- func (g *BenchOutputGroup) FormattRow(line *parse.Benchmark) (row []string)
- func (g *BenchOutputGroup) GetLessFunc(nameCol string) (isLessThan func(int, int) bool)
- func (g *BenchOutputGroup) Sort()
- func (g *BenchOutputGroup) String() string
- func (g *BenchOutputGroup) Tabulate(columnNames []string) *Table
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatAllocsPerOp ¶
FormatAllocsPerOp formats the AllocsPerOp value to an "allocs/op" string.
func FormatBytesAllocPerOp ¶
FormatBytesAllocPerOp formats the AllocedBytesPerOp value to "B/op" string.
func FormatIterations ¶
FormatIterations converts the number of iterations to a string.
func FormatMegaBytesPerSecond ¶
FormatMegaBytesPerSecond formats the MBPerS bench value to "MB/s" string.
Types ¶
type BenchOutputGroup ¶
type BenchOutputGroup struct { ColNameSort string // Column ID to sort by column if not empty Lines []*parse.Benchmark // Benchmark lines parsed Measured int // Columns which are in use }
BenchOutputGroup holds a set of benchmark results and the options used to format them.
func (*BenchOutputGroup) AddLine ¶
func (g *BenchOutputGroup) AddLine(line *parse.Benchmark)
AddLine adds the "line" to the Lines' field and updates Measured field to indicate which measurements ware used.
func (*BenchOutputGroup) ColumnNames ¶
func (g *BenchOutputGroup) ColumnNames() []string
ColumnNames returns a list of column header names according to the current bench results.
func (*BenchOutputGroup) FormatTimeUnit ¶
func (g *BenchOutputGroup) FormatTimeUnit(ns float64) string
FormatTimeUnit uniforms the given nanoseconds (float64) to time unit of ns/μs/ms/s relativelly to the smallest number.
func (*BenchOutputGroup) FormattRow ¶
func (g *BenchOutputGroup) FormattRow(line *parse.Benchmark) (row []string)
FormattRow returns a row with formatted column values from the given benchmark line.
func (*BenchOutputGroup) GetLessFunc ¶
func (g *BenchOutputGroup) GetLessFunc(nameCol string) (isLessThan func(int, int) bool)
GetLessFunc returns a function to compare two lines by the given column name.
func (*BenchOutputGroup) Sort ¶
func (g *BenchOutputGroup) Sort()
Sort sorts by columns specified by command option.
func (*BenchOutputGroup) String ¶
func (g *BenchOutputGroup) String() string
String is a stringer for BenchOutputGroup which returns a formatted strin of the benchmark results.
func (*BenchOutputGroup) Tabulate ¶
func (g *BenchOutputGroup) Tabulate(columnNames []string) *Table
Tabulate returns a Table object with header of the given column names containing formatted comumns.