bigo: Index | Files

package bigo

import ""


Package Files

json.go plot.go result.go runner.go stepper.go util.go


var DefaultPlotConfig = PlotConfig{
    ReferencePlots:       false,
    PlotWidth:            6 * vg.Inch,
    PlotHeight:           6 * vg.Inch,
    LegendThumbNailWidth: 0.5 * vg.Inch,

DefaultPlotConfig is used when calling PlotTestResults

func NewArrayStepper Uses

func NewArrayStepper(steps []float64) *arrayStepper

NewRangeStepper returns a Stepper that steps from the beginning to the end of the provided array.

func NewRangeStepper Uses

func NewRangeStepper(min, max, stepSize float64) *rangeStepper

NewRangeStepper returns a Stepper that steps from min to max incremented by stepSize

func PlotTestResults Uses

func PlotTestResults(name string, plotSeries PlotSeriesList)

PlotTestResults plots the given results to a file prefixed with the given name

func PlotTestResultsWithConfig Uses

func PlotTestResultsWithConfig(name string, plotSeries PlotSeriesList, plotConfig PlotConfig)

PlotTestResultsWithConfig allows to plot with custom configuration

func WriteResultsToJsonFile Uses

func WriteResultsToJsonFile(name string, results Results)

WriteResultsToJson writes the captured results to a json file prefixed with the given name.

type BigO Uses

type BigO struct {
    Name      string
    Runner    TestRunner
    Results   Results
    NStepper  Stepper
    RunConfig RunConfig

BigO holds values and methods to run tests

func New Uses

func New(name string, testRunner TestRunner, stepper Stepper) *BigO

New *BigO

func NewWithConfig Uses

func NewWithConfig(name string, testRunner TestRunner, stepper Stepper, runConfig RunConfig) *BigO

New *BigO with config

func (*BigO) GetResults Uses

func (r *BigO) GetResults() Results

GetResults returns captured results

func (*BigO) PlotResults Uses

func (r *BigO) PlotResults() *BigO

PlotResults plots a graph from the captured results to a png file.

func (*BigO) PlotResultsWithConfig Uses

func (r *BigO) PlotResultsWithConfig(plotConfig PlotConfig) *BigO

PlotResultsWithConfig plots a graph from the captured results to a png file.

func (*BigO) Run Uses

func (r *BigO) Run() *BigO

Run starts a test run, calls the given TestRunner for every N consumed from the given Stepper.

func (*BigO) WriteResultsToJson Uses

func (r *BigO) WriteResultsToJson() *BigO

WriteResultsToJson writes the captured results to a json file.

type OMeasure Uses

type OMeasure struct {
    // ResultValue may be used to store result values of the tested logic.
    // It is not used by this library, it's intention is debugging:
    // If those are deterministic they could be used to cross check that the tested code worked as expected.
    ResultValue interface{} `json:"V"`
    // O represents the number of operations used by the tested program.
    // Determining this value could be from tricky to impossible.
    // For a per machine comparison this could also be the duration of the logic under test.
    O   float64 `json:"O"`

OMeasure is a single capture of the O value

type OMeasures Uses

type OMeasures []OMeasure

OMeasures contains multiple instances of OMeasure

type PlotConfig Uses

type PlotConfig struct {
    ReferencePlots       bool
    PlotWidth            vg.Length
    PlotHeight           vg.Length
    LegendThumbNailWidth vg.Length

PlotConfig enables to configure the plot

type PlotSeries Uses

type PlotSeries struct {
    Name    string
    Results Results

PlotSeries a list of result values assigned to a name

type PlotSeriesList Uses

type PlotSeriesList []PlotSeries

PlotSeriesList a list PlotSeries

type Result Uses

type Result struct {
    N         float64   `json:"N"`
    OMeasures OMeasures `json:"M"`

Result is used by the library to accumulate OMeasure results per N

type Results Uses

type Results []Result

Results contains multiple instances of Result

type RunConfig Uses

type RunConfig struct {
    Speed float64

RunConfig gives detailed configuration to BigO

type Stepper Uses

type Stepper interface {
    Next() (float64, bool)

Stepper implements the Next method. With every call it returned the next N and true. The boolean return parameter will be set to false when there are more steps to process.

type TestRunner Uses

type TestRunner interface {
    Step(n float64) OMeasures

TestRunner runs big o time complexity tests. BigO.Run() calls the Step method for every N and expects OMeasures to be returned.

Package bigo imports 11 packages (graph). Updated 2019-09-22. Refresh now. Tools for package owners.