Skip to content

Commit ed5a25d

Browse files
committed
x/rate is not accurate, use juju/ratelimter instead
1 parent 8c7688b commit ed5a25d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

rb.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77
"runtime"
88
"strconv"
99
"strings"
10+
"time"
1011

11-
"golang.org/x/time/rate"
12-
12+
"github.com/juju/ratelimit"
1313
"github.com/smallnest/redbench"
1414
)
1515

@@ -48,7 +48,8 @@ func main() {
4848
opts.Requests = *n
4949
opts.Pipeline = *pipeline
5050
if *l > 0 {
51-
opts.Limter = rate.NewLimiter(rate.Limit(*l), 1)
51+
rate := int64(*l) / 1000
52+
opts.Limter = ratelimit.NewBucketWithQuantum(time.Millisecond, rate, rate)
5253
}
5354

5455
*t = strings.ToLower(*t)

0 commit comments

Comments
 (0)