periodic

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2018 License: Apache-2.0 Imports: 9 Imported by: 27

Documentation

Overview

Package periodic for fortio (from greek for load) is a set of utilities to run a given task at a target rate (qps) and gather statistics - for instance http requests.

The main executable using the library is fortio but there is also ../histogram to use the stats from the command line and ../echosrv as a very light http server that can be used to test proxies etc like the Istio components.

Index

Constants

View Source
const (
	// Version is the overall package version (used to version json output too).
	Version = "0.6.6"
)

Variables

View Source
var DefaultRunnerOptions = RunnerOptions{
	QPS:         8,
	Duration:    5 * time.Second,
	NumThreads:  4,
	Percentiles: []float64{90.0},
	Resolution:  0.001,
}

DefaultRunnerOptions are the default values for options (do not mutate!). This is only useful for initializing flag default values. You do not need to use this directly, you can pass a newly created RunnerOptions and 0 valued fields will be reset to these defaults.

Functions

This section is empty.

Types

type HasRunnerResult

type HasRunnerResult interface {
	Result() *RunnerResults
}

HasRunnerResult is the interface implictly implemented by HTTPRunnerResults and GrpcRunnerResults so the common results can ge extracted irrespective of the type.

type PeriodicRunner

type PeriodicRunner interface {
	// Starts the run. Returns actual QPS and Histogram of function durations.
	Run() RunnerResults
	// Returns the options normalized by constructor - do not mutate
	// (where is const when you need it...)
	Options() *RunnerOptions
}

PeriodicRunner let's you exercise the Function at the given QPS and collect statistics and histogram about the run.

func NewPeriodicRunner

func NewPeriodicRunner(params *RunnerOptions) PeriodicRunner

NewPeriodicRunner constructs a runner from input parameters/options.

type Runnable added in v0.4.2

type Runnable interface {
	Run(tid int)
}

Runnable are the function to run periodically.

type RunnerOptions

type RunnerOptions struct {
	// Array of objects to run in each thread (use MakeRunners() to clone the same one)
	Runners []Runnable
	// At which (target) rate to run the Runners across NumThreads.
	QPS float64
	// How long to run the test for. Unless Exactly is specified.
	Duration time.Duration
	// Note that this actually maps to gorountines and not actual threads
	// but threads seems like a more familiar name to use for non go users
	// and in a benchmarking context
	NumThreads  int
	Percentiles []float64
	Resolution  float64
	// Where to write the textual version of the results, defaults to stdout
	Out io.Writer
	// Extra data to be copied back to the results (to be saved/JSON serialized)
	Labels string
	// Channel to interrupt a run. If given non nil, will get closed and nil'ed
	// by the end of Run(). To abort a run call Runner.Abort(), don't close channel
	// directly (or risk a panic that it's already closed).
	Stop chan struct{}
	// Mode where an exact number of iterations is requested. Default (0) is
	// to not use that mode. If specified Duration is not used.
	Exactly int64
}

RunnerOptions are the parameters to the PeriodicRunner.

func (*RunnerOptions) Abort added in v0.5.2

func (r *RunnerOptions) Abort()

Abort safely aborts the run by closing the channel and resetting that channel to nil under lock so it can be called multiple times and not create panic for already closed channel.

func (*RunnerOptions) MakeRunners added in v0.4.2

func (r *RunnerOptions) MakeRunners(rr Runnable)

MakeRunners creates an array of NumThreads identical Runnable instances. (for the (rare/test) cases where there is no unique state needed)

func (*RunnerOptions) Normalize added in v0.5.2

func (r *RunnerOptions) Normalize()

Normalize initializes and normalizes the runner options. In particular it sets up the channel that can be used to interrupt the run later.

type RunnerResults

type RunnerResults struct {
	Labels            string
	StartTime         time.Time
	RequestedQPS      string
	RequestedDuration string // String version of the requested duration or exact count
	ActualQPS         float64
	ActualDuration    time.Duration
	NumThreads        int
	Version           string
	DurationHistogram *stats.HistogramData
	Exactly           int64 // Echo back the requested count
}

RunnerResults encapsulates the actual QPS observed and duration histogram.

func (*RunnerResults) ID added in v0.4.2

func (r *RunnerResults) ID() string

ID Returns an id for the result: 64 bytes YYYY-MM-DD-HHmmSS_{alpha_labels} where alpha_labels is the filtered labels with only alphanumeric characters and all non alpha num replaced by _; truncated to 64 bytes.

func (*RunnerResults) Result

func (r *RunnerResults) Result() *RunnerResults

Result returns the common RunnerResults.

Jump to

Keyboard shortcuts

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