diff --git a/load/reporter.go b/load/reporter.go index 444164d..58e0a80 100644 --- a/load/reporter.go +++ b/load/reporter.go @@ -68,6 +68,9 @@ func NewRateReporter(d time.Duration) *RateReporter { func (r *RateReporter) Score() int64 { now := time.Now().UnixNano() passed := now - atomic.SwapInt64(&r.time, now) + if passed == 0 { + return 0 + } if passed < r.unit { atomic.AddInt64(&r.time, -passed) return atomic.LoadInt64(&r.count) * r.unit / passed