Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Pracucci <marco@pracucci.com>
  • Loading branch information
pracucci committed Jul 5, 2023
1 parent c086199 commit 4efab63
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/util/limiter/utilization.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (l *UtilizationBasedLimiter) compute(now time.Time) (currCPUUtil float64, c
// sliding window. During the warmup, the reported CPU utilization will be 0.
if l.firstUpdate.IsZero() {
l.firstUpdate = now
} else if now.Add(-resourceUtilizationSlidingWindow + 1).After(l.firstUpdate) {
} else if now.Sub(l.firstUpdate) >= resourceUtilizationSlidingWindow {
currCPUUtil = float64(l.cpuMovingAvg.Rate()) / 100
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/util/limiter/utilization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func TestUtilizationBasedLimiter_CPUUtilizationSensitivity(t *testing.T) {
}(),
expectedMaxCPUUtilization: 1.49,
},
"10 seconds spike + 110 seconds idle (moving average warmups the first 60 seconds)": {
"10 seconds spike + 110 seconds idle (moving average warms up the first 60 seconds)": {
instantCPUValues: func() []float64 {
values := []float64{10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
values = append(values, generateConstCPUUtilization(110, 0)...)
Expand Down

0 comments on commit 4efab63

Please sign in to comment.