Skip to content

armgit / hey

Public Imported from GitHub
0

HTTP load generator, ApacheBench (ab) replacement

Go

Renaming Boom fields and adding docs.

Burcu Dogand15783ab144f
diff --git a/commands/boom.go b/commands/boom.go
index a6d5918..796abc5 100644
--- a/commands/boom.go
+++ b/commands/boom.go
@@ -28,12 +28,19 @@ type result struct {
}
type Boom struct {
- Req *http.Request
- N int // Number of requests
- C int // Number of Concurrent workers
- T int // Timeout
- Q int // Rate limit (QPS)
- Client *http.Client
+ // Request to make.
+ Req *http.Request
+ // Total number of requests to make.
+ N int
+ // Concurrency level, the number of concurrent workers to run.
+ C int
+ // Timeout in seconds.
+ Timeout int
+ // Rate limit.
+ Qps int
+ // HTTP client to make the requests.
+ Client *http.Client
+ // Option to allow insecure TLS/SSL certificates.
AllowInsecure bool
results chan *result
diff --git a/commands/run.go b/commands/run.go
index aa18385..f32646a 100644
--- a/commands/run.go
+++ b/commands/run.go
@@ -68,8 +68,8 @@ func (b *Boom) run() {
var wg sync.WaitGroup
// Start throttler if rate limit is specified.
var throttle <-chan time.Time
- if b.Q > 0 {
- throttle = time.Tick(time.Duration(1e6/b.Q) * time.Microsecond)
+ if b.Qps > 0 {
+ throttle = time.Tick(time.Duration(1e6/b.Qps) * time.Microsecond)
}
// Start C workers to consume.
for i := 0; i < b.C; i++ {
@@ -79,7 +79,7 @@ func (b *Boom) run() {
// Send N requests.
b.jobs = make(chan bool, b.C)
for i := 0; i < b.N; i++ {
- if b.Q > 0 {
+ if b.Qps > 0 {
<-throttle
}
b.jobs <- true
diff --git a/main.go b/main.go
index 4e80df5..fb896ed 100644
--- a/main.go
+++ b/main.go
@@ -112,7 +112,7 @@ func main() {
req.SetBasicAuth(matches[0][1], matches[0][2])
}
- (&commands.Boom{N: n, C: c, Q: q, T: t, Req: req, AllowInsecure: *flagInsecure}).Run()
+ (&commands.Boom{N: n, C: c, Qps: q, Timeout: t, Req: req, AllowInsecure: *flagInsecure}).Run()
}
func usageAndExit() {