buster

package module
v0.0.0-...-daab398 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

README

buster

GoDoc Build Status Apache V2 License

Buster's a Go library which provides a re-usable framework for load-testing things.

Sometimes you just wanna break stuff.

Buster

Documentation

Overview

Package buster provides a generic framework for load testing.

Specifically, Buster allows you to run a job at a specific concurrency level and a fixed rate while monitoring throughput and latency.

The generic nature of Buster makes it suitable for load testing many different systems—HTTP servers, databases, RPC services, etc.

Example
package main

import (
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"time"

	"github.com/codahale/buster"
)

func main() {
	// run a bench for 1 minute, tracking latencies from 1µs to 1 minute
	bench := buster.Bench{
		Duration:   1 * time.Minute,
		MinLatency: 1 * time.Microsecond,
		MaxLatency: 1 * time.Minute,
	}

	r := bench.Run(
		10,   // concurrent workers
		1000, // 1000 ops/sec total
		func(id int, gen *buster.Generator) error { // the job to be run
			client := &http.Client{}

			return gen.Do(func() error {
				// perform a GET request
				resp, err := client.Get("http://www.google.com/")
				if err != nil {
					return err
				}

				// read the body
				io.Copy(ioutil.Discard, resp.Body)
				return resp.Body.Close()
			})
		},
	)

	fmt.Println(r)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bench

type Bench struct {
	Warmup, Duration, MinLatency, MaxLatency time.Duration
}

A Bench is place where jobs are done.

func (Bench) Run

func (b Bench) Run(concurrency, rate int, job Job) Result

Run runs the given job at the given concurrency level, at the given rate, returning a set of results with aggregated latency and throughput measurements.

func (Bench) Runf

func (b Bench) Runf(concurrency int, rate float64, job Job) Result

Runf runs the given job at the given concurrency level, at the given rate, returning a set of results with aggregated latency and throughput measurements.

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

A Generator is a type passed to Job instances to manage load generation.

func (*Generator) Do

func (gen *Generator) Do(f func() error) error

Do generates load using the given function.

type Job

type Job func(id int, generator *Generator) error

A Job is an arbitrary task.

type Result

type Result struct {
	Concurrency      int
	Elapsed          time.Duration
	Success, Failure uint64
	Latency          *hdrhistogram.Histogram
	Errors           []error
}

A Result is returned after a number of concurrent jobs are run.

func (Result) String

func (r Result) String() string

Jump to

Keyboard shortcuts

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