class_docstr: A running estimate of performance (operations/sec) using adjusted exponential moving average
  :param alpha: Smoothing factor in range [0, 1], [default: 0.1].
docstr: :param task_size: how many items were processed since last call
  :param interval: optionally provide the time delta it took to process this task
  :returns: current estimate of performance (samples per second), but at most
docstr_tok: [":","param","task_size",":","how","many","items","were","processed","since","last","call",":","param","interval",":","optionally","provide","the","time","delta","it","took","to","process","this","task",":","returns",":","current","estimate","of","performance","(","samples","per","second",")",",","but","at","most"]
code: def update(
      self, task_size: float, interval: Optional[float] = None
  ) -> float:
      """
      :param task_size: how many items were processed since last call
      :param interval: optionally provide the time delta it took to process this task
      :returns: current estimate of performance (samples per second), but at most
      """
      assert (
          task_size > 0
      ), f"Can't register processing {task_size} samples"
      if not self.paused:
          self.timestamp, old_timestamp = (
              time.perf_counter(),
              self.timestamp,
          )
          interval = (
              interval
              if interval is not None
              else self.timestamp - old_timestamp
          )
      else:
          assert (
              interval is not None
          ), "If PerformanceEMA is paused, please specify the time interval"
      self.ema_seconds_per_sample = (
          self.alpha * interval / task_size
          + (1 - self.alpha) * self.ema_seconds_per_sample
      )
      self.num_updates += 1
      adjusted_seconds_per_sample = self.ema_seconds_per_sample / (
          1 - (1 - self.alpha) ** self.num_updates
      )
      self.samples_per_second = 1 / max(
          adjusted_seconds_per_sample, self.eps
      )
      return self.samples_per_second
  
file_path: hivemind/hivemind/utils/performance_ema.py
imports: import time
  from contextlib import contextmanager
  from threading import Lock
  from typing import Optional
label_desc: Use image node_id 2 for calling the PerformanceEMA obj's underlying member method code with example usage: obj.update(task_size, interval) and returns: self