Skip to content

Commit

Permalink
actually do rolling window
Browse files Browse the repository at this point in the history
  • Loading branch information
samsja committed Sep 26, 2024
1 parent 0dc5638 commit 867350d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/zeroband/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def __init__(self, window_size: int):
def count_tokens(self, tokens: int):
self.tokens.append(tokens)
self.times.append(time.perf_counter())
if len(self.tokens) > self.window_size:
self.tokens.pop(0)
self.times.pop(0)

def get_tokens_per_second(self) -> float | None:
if len(self.tokens) < 2:
Expand Down

0 comments on commit 867350d

Please sign in to comment.