32 private array $history;
33 private int $nextHistoryIndex = 0;
34 private int $bytesSinceLastRotation = 0;
35 private int $totalBytes = 0;
39 $this->history = array_fill(0, $historySize, 0);
42 public function add(
int $bytes) : void{
43 $this->totalBytes += $bytes;
44 $this->bytesSinceLastRotation += $bytes;
47 public function getTotalBytes() : int{ return $this->totalBytes; }
55 $this->history[$this->nextHistoryIndex] = $this->bytesSinceLastRotation;
56 $this->bytesSinceLastRotation = 0;
57 $this->nextHistoryIndex = ($this->nextHistoryIndex + 1) % count($this->history);
64 return array_sum($this->history) / count($this->history);
67 public function resetHistory() : void{
68 $this->history = array_fill(0, count($this->history), 0);