Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateAverage(data []float64) float64
- func CalculateStandardDeviation(data []float64, avg float64) float64
- func CheckForUpdates(currentVersion string, updateCh *chan string)
- func DurationFromNumber[T numberLike](number T, unit time.Duration) time.Duration
- func Export(formats []string, filename string, results []*SpeedResult, ...)
- func FilterFunc[T any, Ts ~[]T](function func(T) bool, slice Ts) Ts
- func Log(color, message string)
- func MapFunc[Ts ~[]T, Ss ~[]S, T, S any](function func(T) S, slice Ts) Ss
- func ModifyTimeUnit(results []*SpeedResult, timeUnit time.Duration)
- func ParseTimeUnit(unitString string) (time.Duration, error)
- func Plot(plotFormats []string, results []*SpeedResult, timeUnit time.Duration)
- func RelativeSummary(results []*SpeedResult)
- func TestOutliers(data []float64) bool
- func VerifyExportFormats(formats string) ([]string, error)
- func VerifyPlotFormats(formats string) ([]string, error)
- type ByAverage
- type PrintableResult
- type SpeedResult
Constants ¶
const ( RED = "\033[31m" GREEN = "\033[32m" YELLOW = "\033[33m" BLUE = "\033[34m" PURPLE = "\033[35m" CYAN = "\033[36m" RESET = "\033[0m" )
colors
Variables ¶
var ErrInvalidTimeUnit = errors.New("invalid time unit")
var NO_COLOR bool = false
NO_COLOR is a global variable that can be set to disable color output.
var OUTLIER_THRESHOLD = 0.0
can be modified by the outlier-threshold flag
Functions ¶
func CalculateAverage ¶
func CalculateStandardDeviation ¶
Computes the standard deviation of the given data.
func CheckForUpdates ¶
func DurationFromNumber ¶
func Export ¶
func Export(formats []string, filename string, results []*SpeedResult, timeUnit time.Duration)
func FilterFunc ¶
FilterFunc takes a predicate function and returns all the elements of the slice which return true for the function.
func Log ¶
func Log(color, message string)
todo refactor this to use colorstring module Log prints the given message in the given color.
func MapFunc ¶
func MapFunc[Ts ~[]T, Ss ~[]S, T, S any](function func(T) S, slice Ts) Ss
MapFunc returns a slice of all elements in the given slice mapped by the given function.
func ModifyTimeUnit ¶
func ModifyTimeUnit(results []*SpeedResult, timeUnit time.Duration)
ModifyTimeUnit takes a slice of SpeedResult and modifies its every attribute to suit accordingly to the given timeUnit.
func RelativeSummary ¶
func RelativeSummary(results []*SpeedResult)
Prints the relative summary and also sets the RelativeMean and RelativeStddev of each SpeedResult.
func TestOutliers ¶
Returns true if there are any statistical outliers in the data.
func VerifyExportFormats ¶
func VerifyPlotFormats ¶
Types ¶
type ByAverage ¶
type ByAverage []*SpeedResult
Implements sort.Interface for []Result based on the Average field.
type PrintableResult ¶
type PrintableResult struct { Command string Runs int AverageElapsed string AverageUser string AverageSystem string StandardDeviation string Min string Max string }
PrintableResult struct which is shown at the end as benchmarking summary and is written to a file. Other numerical quantities except runs are represented as strings because they are durations, and time.Duration offers a .String() method.
func NewPrintableResult ¶
func NewPrintableResult() *PrintableResult
func (*PrintableResult) FromSpeedResult ¶
func (pr *PrintableResult) FromSpeedResult(sr SpeedResult) *PrintableResult
func (*PrintableResult) String ¶
func (result *PrintableResult) String() string
Consolify prints the benchmark summary of the Result struct to the console, with color codes.
type SpeedResult ¶
type SpeedResult struct { Command string `json:"command,omitempty"` AverageElapsed float64 `json:"mean,omitempty"` AverageUser float64 `json:"user,omitempty"` AverageSystem float64 `json:"system,omitempty"` StandardDeviation float64 `json:"stddev,omitempty"` Max float64 `json:"max,omitempty"` Min float64 `json:"min,omitempty"` Times []float64 `json:"times,omitempty"` RelativeMean float64 `json:"relative_mean,omitempty"` RelativeStddev float64 `json:"relative_stddev,omitempty"` }
Contains all the numerical quantities (in microseconds) for relative speed comparison. Also used for export.