prettify

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: MIT Imports: 8 Imported by: 0

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

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatAllocsPerOp

func FormatAllocsPerOp(l *parse.Benchmark) string

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

func FormatBytesAllocPerOp

func FormatBytesAllocPerOp(l *parse.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 *parse.Benchmark) string

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.

type Table

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

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

Jump to

Keyboard shortcuts

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