pewpew

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
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 added in v1.0.0

func CreateTextSummary(reqStatSummary RequestStatSummary) string

CreateTextSummary creates a human friendly summary of entire test

func RunBenchmark added in v1.0.0

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 added in v1.0.0

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

	DNSPrefetch     bool
	Timeout         string
	Method          string
	Body            string
	BodyFilename    string
	Headers         string
	Cookies         string
	UserAgent       string
	BasicAuth       string
	Compress        bool
	KeepAlive       bool
	FollowRedirects bool
	NoHTTP2         bool
	EnforceSSL      bool
}

BenchmarkConfig is the top level struct that contains the configuration for a benchmark test

func NewBenchmarkConfig added in v1.0.0

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

	DNSPrefetch     bool
	Timeout         string
	Method          string
	Body            string
	BodyFilename    string
	Headers         string
	Cookies         string
	UserAgent       string
	BasicAuth       string
	Compress        bool
	KeepAlive       bool
	FollowRedirects bool
	NoHTTP2         bool
	EnforceSSL      bool
}

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
	//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
}

Target is location of where send the HTTP request and how to send it.

Jump to

Keyboard shortcuts

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