Skip to content

Commit

Permalink
Allow QPS to be less than 1 (rakyll#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinvaneyk authored and mdakin committed Dec 26, 2017
1 parent 59fcb32 commit d6f8b18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions hey.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand All @@ -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 cannot
be 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 response
metrics in comma-separated values format.
Expand Down
6 changes: 3 additions & 3 deletions requester/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 response
DisableCompression bool
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit d6f8b18

Please sign in to comment.