|
|
@ -74,7 +74,10 @@ func (rw *RollingWindow) span() int {
|
|
|
|
|
|
|
|
|
|
|
|
func (rw *RollingWindow) updateOffset() {
|
|
|
|
func (rw *RollingWindow) updateOffset() {
|
|
|
|
span := rw.span()
|
|
|
|
span := rw.span()
|
|
|
|
if span > 0 {
|
|
|
|
if span <= 0 {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
offset := rw.offset
|
|
|
|
offset := rw.offset
|
|
|
|
start := offset + 1
|
|
|
|
start := offset + 1
|
|
|
|
steps := start + span
|
|
|
|
steps := start + span
|
|
|
@ -95,7 +98,6 @@ func (rw *RollingWindow) updateOffset() {
|
|
|
|
rw.offset = (offset + span) % rw.size
|
|
|
|
rw.offset = (offset + span) % rw.size
|
|
|
|
rw.lastTime = timex.Now()
|
|
|
|
rw.lastTime = timex.Now()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type Bucket struct {
|
|
|
|
type Bucket struct {
|
|
|
|
Sum float64
|
|
|
|
Sum float64
|
|
|
|