Change average from int to int64 in order to support 32-bit systems. (#4921)

This commit is contained in:
Andrej Pregl 2017-09-14 19:23:23 +02:00 committed by Dee Koder
parent 3e632a49ee
commit f45e0a44b8

View File

@ -88,16 +88,16 @@ func (dt *dynamicTimeout) logEntry(duration time.Duration) {
// previous results // previous results
func (dt *dynamicTimeout) adjust(entries [dynamicTimeoutLogSize]time.Duration) { func (dt *dynamicTimeout) adjust(entries [dynamicTimeoutLogSize]time.Duration) {
failures, average := 0, 0 failures, average := 0, int64(0)
for i := 0; i < len(entries); i++ { for i := 0; i < len(entries); i++ {
if entries[i] == maxDuration { if entries[i] == maxDuration {
failures++ failures++
} else { } else {
average += int(entries[i]) average += int64(entries[i])
} }
} }
if failures < len(entries) { if failures < len(entries) {
average /= len(entries) - failures average /= int64(len(entries) - failures)
} }
timeOutHitPct := float64(failures) / float64(len(entries)) timeOutHitPct := float64(failures) / float64(len(entries))