stats

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package stats Provides the StatBenchmark type that is capable of getting statistics for a benchmark given number of iterations.

Package stats Utilities that help calculating statistical measures.

Index

Constants

View Source
const (

	// Mean opt
	Mean StatType = "mean"
	// Sum opt
	Sum = "sum"
	// Mode opt
	Mode = "mode"
	// Highest opt
	Highest = "highest"
	// Lowest opt
	Lowest = "lowest"

	// Range opt
	Range = "range"

	// All opt
	All = "all"

	// Graph opt
	Graph = "graph"
)

Variables

This section is empty.

Functions

func PlotData

func PlotData(data map[string]time.Duration) bool

PlotData plots the data given a map of iterations and durations. BUG(r) Function does not work as expected.

Types

type BenchmarkStat

type BenchmarkStat struct {
	// contains filtered or unexported fields
}

BenchmarkStat represents a statistical Benchmark

func NewBenchmarkStat

func NewBenchmarkStat(benchmark bmark.Benchmark, options ...StatType) BenchmarkStat

NewBenchmarkStat create a new Benchmark with statistics qualities NewBenchmarkStat(benchmark, "mean", "mode") || NewBenchmarkStat(benchmark, stats.Mean, stats.Mode)

func (BenchmarkStat) GetStat

func (benchmark BenchmarkStat) GetStat(what StatType) (string, error)

GetStat return a computed StatType

func (*BenchmarkStat) PrintStats

func (benchmark *BenchmarkStat) PrintStats()

PrintStats prints the selected stats options.

type Counter

type Counter struct {
	*List
	// contains filtered or unexported fields
}

Counter A type composed from List capable of keeping track of each element in a key value pair.

func NewCounter

func NewCounter(list *List) Counter

NewCounter creates a new Counter.

func (*Counter) Add

func (counter *Counter) Add(e float64)

Add add to counter, if element exists then increment count. Does this in a separate map and also adds to the main item array.

func (*Counter) AddByArray

func (counter *Counter) AddByArray(arr []float64)

AddByArray add to the Counter and List by an array. OPTION() Can remove the abstraction.

func (*Counter) GetCommon

func (counter *Counter) GetCommon() float64

GetCommon returns the mode of the data.

type List

type List struct {
	// contains filtered or unexported fields
}

List base list type

func NewList

func NewList() *List

NewList create a new list.

func (*List) Add

func (list *List) Add(e float64)

Add add item to the list.

func (*List) Equal

func (list *List) Equal(other interface{}) bool

Equal Check whether two interfaces (Only List and Counter) are equal.

func (*List) GetHighest

func (list *List) GetHighest() float64

GetHighest return the higest value.

func (*List) GetLowest

func (list *List) GetLowest() float64

GetLowest return the lowest value.

func (*List) GetMean

func (list *List) GetMean() float64

GetMean return the mean of items.

func (*List) GetSum

func (list *List) GetSum() float64

GetSum return the sum of items.

func (List) String

func (list List) String() string

String string representation of a list.

type StatType

type StatType string

StatType represents a statistical measure.

Notes

Bugs

  • Function does not work as expected.

Jump to

Keyboard shortcuts

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