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 ¶
A Bench is place where jobs are done.
Click to show internal directories.
Click to hide internal directories.
