Added thread debug option

CoreConfig now have a boolean thread debug option, when this is enabled,
it prints out the CPU usage of each thread to help identify which
threads are the most CPU hungry for later optimisation
This commit is contained in:
h3cx committed 2026-09-17 22:47:54 +02:00
1 parent 2e8155142e
commit 563a35ee2c
4 files changed
+143 -13

No files matched your search

+13 -12
View File
@@ -28,7 +28,7 @@ HOST = "127.0.0.1"
PORT = 8765
DISPLAY_FREQUENCY_HZ = 5.0
LOG_HISTORY_SIZE = 1_000
VISIBLE_LOG_LINES = 12
VISIBLE_LOG_LINES = 20
signal_id_1: UUID = UUID("3f32cea3-d872-4c16-a0a2-54b57171aeb2")
signal_id_2: UUID = UUID("6578ac37-99d1-410c-b3f7-d049339919b2")
@@ -55,9 +55,7 @@ class TuiLogHandler(logging.Handler):
def __init__(self) -> None:
super().__init__()
self._entries: deque[tuple[str, str, str, str]] = deque(
maxlen=LOG_HISTORY_SIZE
)
self._entries: deque[tuple[str, str, str, str]] = deque(maxlen=LOG_HISTORY_SIZE)
self._lock = Lock()
self.setFormatter(
logging.Formatter(
@@ -275,10 +273,10 @@ def main() -> None:
dynalab_logger.setLevel(logging.DEBUG)
dynalab_logger.propagate = False
dynalab_logger.addHandler(log_handler)
config = CoreConfig(host=HOST, port=PORT)
config = CoreConfig(host=HOST, port=PORT, thread_debug=False)
core = Core(config)
processing_source = Path(__file__).with_name("process.py").read_text(
encoding="utf-8"
processing_source = (
Path(__file__).with_name("process.py").read_text(encoding="utf-8")
)
dashboard = Dashboard(core, config, log_handler)
@@ -312,11 +310,14 @@ def main() -> None:
try:
core.start()
with keyboard_input(), Live(
dashboard.render(),
auto_refresh=False,
screen=False,
) as live:
with (
keyboard_input(),
Live(
dashboard.render(),
auto_refresh=False,
screen=False,
) as live,
):
while dashboard.running:
update_started = time.monotonic()