plan

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStopped = errors.New("plan stopped")

ErrStopped is returned when the Stop method has been called on the Plan instance. A new Plan must be created.

Functions

This section is empty.

Types

type DoFunc

type DoFunc func(data *record.Person, rid idgen.Generator, rnd *rand.Rand) bool

DoFunc defines a database operation.

If a DoFunc returns false, it's latency measurement is abandoned and it's call does not count towards the operation limit. Implementations of DoFunc should return false when an error occurs.

type Plan

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

Plan defines a series of operations to perform.

A Plan concurrently runs the configured number of workers, each performing operations in sequence and measuring their latency.

A Plan stops the workers when the configured maximum number of operations is reached, or Stop is called.

func New

func New(opsMax uint64, paddingSize uint64) *Plan

New returns an empty Plan, configured to run opsMax number of operations, with paddingSize amount of randomised binary record padding.

func (*Plan) Add

func (p *Plan) Add(name string, f DoFunc)

Add pushes a new operation into the Plan run list.

Each worker will run all operations in the sequence provided to Add.

func (*Plan) Run

func (p *Plan) Run(workers uint64, statusW io.Writer) []Result

Run starts workers number of concurrent workers, and writes a description (including approximate average throughput) of each operation every second to w.

When complete, the operation statistics from each worker are aggregated and returned.

func (*Plan) SetIDGenerator

func (p *Plan) SetIDGenerator(id idgen.GeneratorSource)

SetIDGenerator configures PLan to use id as it's ID generator.

func (*Plan) Stop

func (p *Plan) Stop()

Stop causes any remaining work to be abandoned and immediately aggregates all the statistics from the workers.

A Plan will complete any in-progress blocking operations before returning from Run. Once stopped, a Plan cannot be resumed.

type Result

type Result struct {
	Name      string
	Histogram *dstats.Histogram
}

Result provides the name of an operation run as part of a Plan, and the associated latency histogram for all it's calls.

Jump to

Keyboard shortcuts

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