Skip to content

Commit

Permalink
chore: s/houseKeeping/removeExpiredEntries/g
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWhitehead committed Jul 31, 2023
1 parent 203ee70 commit 2c436a5
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ private ThroughputMovingWindow(Duration window) {
}

void add(Instant now, Throughput value) {
houseKeeping(now);
removeExpiredEntries(now);
values.add(new Entry(now, value));
}

Throughput avg(Instant now) {
houseKeeping(now);
removeExpiredEntries(now);
return values.stream()
.map(Entry::getValue)
.reduce(
Throughput.zero(),
(tp1, tp2) -> Throughput.of(tp1.getNumBytes() + tp2.getNumBytes(), window));
}

private void houseKeeping(Instant now) {
private void removeExpiredEntries(Instant now) {
Instant newMin = now.minus(window);
values.removeIf(e -> lteq(e.getAt(), newMin));
}
Expand Down

0 comments on commit 2c436a5

Please sign in to comment.