benchmark

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoMode is raised when tehre is no mode token after \benchmark.
	ErrNoMode = errors.New("failed to parse \\benchmark line, missing mode")
	// ErrNoName is raised when there is no token after \name.
	ErrNoName = errors.New("missing name after \\name token")
)

Functions

func RandDate

func RandDate() string

func RandFloat64Between

func RandFloat64Between(min float64, max float64) float64

func RandInt

func RandInt(min int, max int) int

func RandStringBytes

func RandStringBytes(min int, max int) string

Types

type BenchType

type BenchType int

BenchType determines if the particular benchmark should be run several times or only once.

const (
	// TypeLoop executes the benchmark several times.
	TypeLoop BenchType = iota
	// TypeOnce executes the benchmark once.
	TypeOnce BenchType = iota
)

type Bencher

type Bencher interface {
	Setup()
	Cleanup(bool)
	Benchmarks() []Benchmark
	Exec(string)
}

Bencher is the interface a benchmark has to impelement.

type Benchmark

type Benchmark struct {
	Name      string
	Type      BenchType
	IterRatio float64
	Parallel  bool
	Stmt      string
}

Benchmark contains the benchmark name, its db statement and its type.

func ParseScript

func ParseScript(r io.Reader) ([]Benchmark, error)

ParseScript parses a benchmark script and returns the benchmarks.

type Result

type Result struct {
	Min                    time.Duration
	Max                    time.Duration
	ExecutionTimes         []time.Duration
	TotalExecutionTime     time.Duration
	TotalExecutionTimeMult time.Duration
	Start                  time.Time
	End                    time.Time
	Duration               time.Duration
	TotalExecutionCount    uint64
}

Result encapsulates the metrics of a benchmark run

func Run

func Run(bencher Bencher, b Benchmark, iter, threads int) Result

Run executes the benchmark.

func (Result) ArithMean

func (r Result) ArithMean() time.Duration

Calculates the results arithmetic mean

func (Result) GeoMean

func (r Result) GeoMean() time.Duration

Calculates the results geometric mean

Jump to

Keyboard shortcuts

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