periodic

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2017 License: Apache-2.0 Imports: 10 Imported by: 23

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 cmd/fortio but there is also cmd/histogram to use the stats from the command line and cmd/echosrv as a very light http server that can be used to test proxies etc like the Istio components.

Index

Constants

This section is empty.

Variables

View Source
var DefaultRunnerOptions = RunnerOptions{
	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

func ParsePercentiles

func ParsePercentiles(percentiles string) ([]float64, error)

ParsePercentiles extracts the percentiles from string (flag).

Types

type Function

type Function func(tid int)

Function to run periodically.

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 RunnerOptions

type RunnerOptions struct {
	Function Function
	QPS      float64
	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
}

RunnerOptions are the parameters to the PeriodicRunner.

type RunnerResults

type RunnerResults struct {
	DurationHistogram *stats.Histogram
	ActualQPS         float64
	ActualDuration    time.Duration
}

RunnerResults encapsulates the actual QPS observed and duration histogram.

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