Skip to content

armgit / hey

Public Imported from GitHub
0

HTTP load generator, ApacheBench (ab) replacement

Go

Use time.NewTicker() which returns a stoppable ticker

JBD18a4569ad479
diff --git a/requester/requester.go b/requester/requester.go
index 652e460..6ee2986 100644
--- a/requester/requester.go
+++ b/requester/requester.go
@@ -208,7 +208,9 @@ 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 {
- throttle = time.Tick(time.Duration(1e6/(b.QPS)) * time.Microsecond)
+ ticker := time.NewTicker(time.Duration(1e6/(b.QPS)) * time.Microsecond)
+ defer ticker.Stop()
+ throttle = ticker.C
}
if b.DisableRedirects {