INNER CODE UNIT · Python
PerformanceMonitor
nachifur/MulimgViewer · src/mulimgviewer/src/main.py:33
class PerformanceMonitor:
"""Lightweight collector for extraction/stitch/render metrics."""
def __init__(self, eval_batch_window=15, eval_time_window=10.0):
self.extract_history = deque(maxlen=60)
self.stitch_history = deque(maxlen=60)
self.render_history = deque(maxlen=30)
self.buffer_history = deque(maxlen=60)
self.eval_batch_window = max(1, int(eval_batch_window))
self.eval_time_window = max(1.0, float(eval_time_window))
self.processed_batches = 0
self.last_eval_batch = 0
self.last_eval_time = 0.0
self.last_render_timestamp = None
def record_extract(self, duration):
if duration is not None and duration >= 0:
self.extract_history.append(float(duration))