package
0.2.0
Repository: https://github.com/keinos/go-prettybench.git
Documentation: pkg.go.dev

# README

prettify

import "github.com/KEINOS/go-prettybench/prettify"

Package prettify provides a set of functions to format benchmark results prettily.

Index

func FormatAllocsPerOp

func FormatAllocsPerOp(l *bench.Benchmark) string

FormatAllocsPerOp formats the AllocsPerOp value to an "allocs/op" string.

func FormatBytesAllocPerOp

func FormatBytesAllocPerOp(l *bench.Benchmark) string

FormatBytesAllocPerOp formats the AllocedBytesPerOp value to "B/op" string.

func FormatIterations

func FormatIterations(iter int) string

FormatIterations converts the number of iterations to a string.

func FormatMegaBytesPerSecond

func FormatMegaBytesPerSecond(l *bench.Benchmark) string

FormatMegaBytesPerSecond formats the MBPerS bench value to "MB/s" string.

type BenchOutputGroup

BenchOutputGroup holds a set of benchmark results and the options used to format them.

type BenchOutputGroup struct {
    ColNameSort string             // Column ID to sort by column if not empty
    Lines       []*bench.Benchmark // Benchmark lines parsed
    Measured    int                // Columns which are in use
}

func (*BenchOutputGroup) AddLine

func (g *BenchOutputGroup) AddLine(line *bench.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 *bench.Benchmark) (row []string)

FormattRow returns a row with formatted column values from the given benchmark line.

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.

type Table

Table holds a set of cells and the maximum width of each column.

type Table struct {
    MaxLengths []int
    Cells      [][]string
}

Generated by gomarkdoc

# Functions

FormatAllocsPerOp formats the AllocsPerOp value to an "allocs/op" string.
FormatBytesAllocPerOp formats the AllocedBytesPerOp value to "B/op" string.
FormatIterations converts the number of iterations to a string.
FormatMegaBytesPerSecond formats the MBPerS bench value to "MB/s" string.

# Structs

BenchOutputGroup holds a set of benchmark results and the options used to format them.
Table holds a set of cells and the maximum width of each column.