Documentation ¶
Index ¶
- Constants
- func CreateTextSummary(reqStatSummary RequestStatSummary) string
- func RunBenchmark(b BenchmarkConfig, w io.Writer) ([][]RequestStat, error)
- func RunStress(s StressConfig, w io.Writer) ([][]RequestStat, error)
- type BenchmarkConfig
- type RequestStat
- type RequestStatSummary
- type StressConfig
- type Target
- type TargetOptions
Constants ¶
const ( DefaultURL = "http://localhost" DefaultTimeout = "10s" DefaultMethod = "GET" DefaultUserAgent = "pewpew" DefaultCount = 10 DefaultConcurrency = 1 DefaultRPS = 10 DefaultDuration = 15 )
Reasonable default values for a target
Variables ¶
This section is empty.
Functions ¶
func CreateTextSummary ¶
func CreateTextSummary(reqStatSummary RequestStatSummary) string
CreateTextSummary creates a human friendly summary of entire test
func RunBenchmark ¶
func RunBenchmark(b BenchmarkConfig, w io.Writer) ([][]RequestStat, error)
RunBenchmark starts the benchmark tests with the provided BenchmarkConfig. Throughout the test, data is sent to w, useful for live updates.
func RunStress ¶
func RunStress(s StressConfig, w io.Writer) ([][]RequestStat, error)
RunStress starts the stress tests with the provided StressConfig. Throughout the test, data is sent to w, useful for live updates.
Types ¶
type BenchmarkConfig ¶
type BenchmarkConfig struct { Verbose bool Quiet bool //RPS is the requests per second rate to make for each Target RPS int //Duration is the number of seconds to run the benchmark test Duration int Targets []Target //global target settings Options TargetOptions }
BenchmarkConfig is the top level struct that contains the configuration for a benchmark test
func NewBenchmarkConfig ¶
func NewBenchmarkConfig() (b *BenchmarkConfig)
NewBenchmarkConfig creates a new BenchmarkConfig with package defaults
type RequestStat ¶
type RequestStat struct { Proto string URL string Method string StartTime time.Time `json:"startTime"` EndTime time.Time `json:"endTime"` //equivalent to the difference between StartTime and EndTime Duration time.Duration `json:"duration"` //HTTP Status Code, e.g. 200, 404, 503 StatusCode int `json:"statusCode"` Error error `json:"error"` DataTransferred int //bytes }
RequestStat is the saved information about an individual completed HTTP request
type RequestStatSummary ¶
type RequestStatSummary struct {
// contains filtered or unexported fields
}
RequestStatSummary is an aggregate statistical summary of a set of RequestStats
func CreateRequestsStats ¶
func CreateRequestsStats(requestStats []RequestStat) RequestStatSummary
CreateRequestsStats creates a statistical summary out of the individual RequestStats
type StressConfig ¶
type StressConfig struct { Verbose bool Quiet bool //Count is how many total requests to make for each Target Count int //Concurrency is how many requests can be happening simultaneously for each Target Concurrency int Targets []Target //global target settings Options TargetOptions }
StressConfig is the top level struct that contains the configuration for a stress test
func NewStressConfig ¶
func NewStressConfig() (s *StressConfig)
NewStressConfig creates a new StressConfig with package defaults
type Target ¶
type Target struct { URL string //Whether or not to interpret the URL as a regular expression string //and generate actual target URLs from that RegexURL bool Options TargetOptions }
Target is location of where send the HTTP request and how to send it.
type TargetOptions ¶
type TargetOptions struct { //whether or not to resolve hostname to IP address before making request, //eliminating that aspect of timing DNSPrefetch bool Timeout string //A valid HTTP method: GET, HEAD, POST, etc. Method string //String that is the content of the HTTP body. Empty string is no body. Body string // Whether or not to interpret the Body as regular expression string // and generate actual body from that RegexBody bool //A location on disk to read the HTTP body from. Empty string means it will not be read. BodyFilename string Headers string Cookies string UserAgent string BasicAuth string Compress bool KeepAlive bool FollowRedirects bool NoHTTP2 bool EnforceSSL bool }
TargetOptions is the configuration for a Target