HTTP load generator, ApacheBench (ab) replacement
Go
Allow QPS to be less than 1 (#52)
Erwin van Eykd6f8b187def0
diff --git a/hey.go b/hey.goindex eaf0cdc..377066f 100644--- a/hey.go+++ b/hey.go@@ -49,7 +49,7 @@ var (c = flag.Int("c", 50, "")n = flag.Int("n", 200, "")- q = flag.Int("q", 0, "")+ q = flag.Float64("q", 0, "")t = flag.Int("t", 20, "")h2 = flag.Bool("h2", false, "")@@ -67,7 +67,7 @@ Options:-n Number of requests to run. Default is 200.-c Number of requests to run concurrently. Total number of requests cannotbe smaller than the concurrency level. Default is 50.- -q Rate limit, in seconds (QPS).+ -q Rate limit, in queries per second (QPS). Default is no rate limit.-o Output type. If none provided, a summary is printed."csv" is the only supported alternative. Dumps the responsemetrics in comma-separated values format.diff --git a/requester/requester.go b/requester/requester.goindex 838f4d5..4df558f 100644--- a/requester/requester.go+++ b/requester/requester.go@@ -66,8 +66,8 @@ type Work struct {// Timeout in seconds.Timeout int- // Qps is the rate limit.- QPS int+ // Qps is the rate limit in queries per second.+ QPS float64// DisableCompression is an option to disable compression in responseDisableCompression bool@@ -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 {+ if b.QPS > 0.0 {throttle = time.Tick(time.Duration(1e6/(b.QPS)) * time.Microsecond)}