Documentation ¶
Overview ¶
Package bench provides a generic framework for performing latency benchmarks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Benchmark ¶
type Benchmark struct {
// contains filtered or unexported fields
}
Benchmark performs a system benchmark by attempting to issue requests at a specified rate and capturing the latency distribution. The request rate is divided across the number of configured connections.
func NewBenchmark ¶
func NewBenchmark(factory RequesterFactory, requestRate, connections uint64, duration time.Duration, burst uint64) *Benchmark
NewBenchmark creates a Benchmark which runs a system benchmark using the given RequesterFactory. The requestRate argument specifies the number of requests per second to issue. This value is divided across the number of connections specified, so if requestRate is 50,000 and connections is 10, each connection will attempt to issue 5,000 requests per second. A zero value disables rate limiting entirely. The duration argument specifies how long to run the benchmark. Requests will be issued in bursts with the specified burst rate. If burst == 0 then burst will be the lesser of (0.1 * requestRate) and 1000 but at least 1.
type Requester ¶
type Requester interface { // Setup prepares the Requester for benchmarking. Setup() error // Request performs a synchronous request to the system under test. Request() error // Teardown is called upon benchmark completion. Teardown() error }
Requester synchronously issues requests for a particular system under test.
type RequesterFactory ¶
type RequesterFactory interface { // GetRequester returns a new Requester, called for each Benchmark // connection. GetRequester(number uint64) Requester }
RequesterFactory creates new Requesters.
type Summary ¶
type Summary struct { Connections uint64 RequestRate uint64 SuccessTotal uint64 ErrorTotal uint64 TimeElapsed time.Duration SuccessHistogram *hdrhistogram.Histogram UncorrectedSuccessHistogram *hdrhistogram.Histogram ErrorHistogram *hdrhistogram.Histogram UncorrectedErrorHistogram *hdrhistogram.Histogram Throughput float64 }
Summary contains the results of a Benchmark run.
func (*Summary) GenerateErrorLatencyDistribution ¶
func (s *Summary) GenerateErrorLatencyDistribution(percentiles histwriter.Percentiles, file string) error
GenerateErrorLatencyDistribution generates a text file containing the specified latency distribution (of requests that resulted in errors) in a format plottable by http://hdrhistogram.github.io/HdrHistogram/plotFiles.html. Percentiles is a list of percentiles to include, e.g. 10.0, 50.0, 99.0, 99.99, etc. If percentiles is nil, it defaults to a logarithmic percentile scale. If a request rate was specified for the benchmark, this will also generate an uncorrected distribution file which does not account for coordinated omission.
func (*Summary) GenerateLatencyDistribution ¶
func (s *Summary) GenerateLatencyDistribution(percentiles histwriter.Percentiles, file string) error
GenerateLatencyDistribution generates a text file containing the specified latency distribution in a format plottable by http://hdrhistogram.github.io/HdrHistogram/plotFiles.html. Percentiles is a list of percentiles to include, e.g. 10.0, 50.0, 99.0, 99.99, etc. If percentiles is nil, it defaults to a logarithmic percentile scale. If a request rate was specified for the benchmark, this will also generate an uncorrected distribution file which does not account for coordinated omission.