You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is my test function:
func TestName(t *testing.T) {
rl := New(1)
prev := time.Now()
var sizes = 0
for i := 0; i < 100000; i++ {
sizes++
if sizes >= 1000 {
now := rl.Take()
fmt.Println(sizes, i, now.Sub(prev))
prev = now
if 4000 < i && i < 5000 {
time.Sleep(30 * time.Second)
}
sizes = 0
}
}
Here is my test function:
func TestName(t *testing.T) {
rl := New(1)
}
the result i expected:
1000 999 2µs
1000 1999 1s
1000 2999 1s
1000 3999 1s
1000 4999 1s
1000 5999 30.00147s
1000 6999 1s
1000 7999 1s
1000 8999 1s
1000 9999 1s
1000 10999 1s
1000 11999 1s
1000 12999 1s
I get the result:
1000 999 3µs
1000 1999 1s
1000 2999 1s
1000 3999 1s
1000 4999 1s
1000 5999 30.001429s
1000 6999 326µs
1000 7999 34µs
1000 8999 7µs
1000 9999 6µs
1000 10999 6µs
1000 11999 6µs
1000 12999 6µs
1000 13999 6µs
1000 14999 6µs
1000 15999 6µs
1000 16999 6µs
1000 17999 6µs
1000 18999 6µs
I got the desired result after modifying the code here:
pkg : ratelimit
fileName : limiter_atomic_int64.go
funcName : func (t *atomicInt64Limiter) Take() time.Time
line : 76
update
newTimeOfNextPermissionIssue = now - int64(t.maxSlack)
to
newTimeOfNextPermissionIssue = now)
The text was updated successfully, but these errors were encountered: