HTTP load generator, ApacheBench (ab) replacement
Go
Minor shuffle. Throttle only if we are sending somthing, remove message. (#77)
mdakinaae813562e0e
diff --git a/hey.go b/hey.goindex 377066f..6b0b9a8 100644--- a/hey.go+++ b/hey.go@@ -212,7 +212,6 @@ func main() {signal.Notify(c, os.Interrupt)go func() {<-c- fmt.Fprintf(os.Stderr, "\nInterrupted, stopping workers.")w.Stop()}()w.Run()diff --git a/requester/requester.go b/requester/requester.goindex 4df558f..0a7265b 100644--- a/requester/requester.go+++ b/requester/requester.go@@ -197,7 +197,7 @@ func (b *Work) makeRequest(c *http.Client) {func (b *Work) runWorker(client *http.Client, n int) {var throttle <-chan time.Time- if b.QPS > 0.0 {+ if b.QPS > 0 {throttle = time.Tick(time.Duration(1e6/(b.QPS)) * time.Microsecond)}@@ -207,14 +207,14 @@ func (b *Work) runWorker(client *http.Client, n int) {}}for i := 0; i < n; i++ {- if b.QPS > 0 {- <-throttle- }// Check if application is stopped. Do not send into a closed channel.select {case <-b.stopCh:returndefault:+ if b.QPS > 0 {+ <-throttle+ }b.makeRequest(client)}}