From d4cbe110d69332aa826e534e1a51e34df0f886e7 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Tue, 26 May 2026 14:07:50 +0200 Subject: [PATCH] gui_client: debounce plot redraws to speed up initial record import Replace direct _redraw() calls in PlotTab.update() with a 100 ms single-shot QTimer. During a burst of incoming records (e.g. 500 history records on connect) only the data is accumulated; a single redraw fires 100 ms after the last record arrives instead of once per record (~4000 pyqtgraph redraws avoided). Co-Authored-By: Claude Sonnet 4.6 --- gui_client.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gui_client.py b/gui_client.py index 3dad8f1..256b8dc 100644 --- a/gui_client.py +++ b/gui_client.py @@ -20,7 +20,7 @@ from collections import deque from datetime import datetime from pathlib import Path -from PyQt5.QtCore import QObject, Qt, pyqtSignal +from PyQt5.QtCore import QObject, QTimer, Qt, pyqtSignal from PyQt5.QtGui import QColor, QFont from PyQt5.QtWidgets import ( QApplication, QComboBox, QFormLayout, QGridLayout, QGroupBox, @@ -382,6 +382,11 @@ class PlotTab(QWidget): self._series: dict[str, deque] = {} self._units: dict[str, str] = {} + self._redraw_timer = QTimer(self) + self._redraw_timer.setSingleShot(True) + self._redraw_timer.setInterval(100) + self._redraw_timer.timeout.connect(self._redraw) + # ── 4×2 scrollable plot grid (each cell: control bar + plot) ───────── plot_container = QWidget() plot_grid = QGridLayout(plot_container) @@ -521,6 +526,7 @@ class PlotTab(QWidget): # ── public API ──────────────────────────────────────────────────────────── def clear_data(self): + self._redraw_timer.stop() self._series.clear() self._units.clear() self._redraw() @@ -550,7 +556,7 @@ class PlotTab(QWidget): if new_keys: self._refresh_combos() - self._redraw() + self._redraw_timer.start() # ── combo refresh + saved-trace restore ──────────────────────────────────