From 0be87d8b4f1fa258a5cd32188eccd4aa22b7446e Mon Sep 17 00:00:00 2001 From: Hemna Date: Tue, 5 Nov 2024 11:54:07 -0500 Subject: [PATCH] Calculate delta once and reuse it --- aprsd/cmds/listen.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/aprsd/cmds/listen.py b/aprsd/cmds/listen.py index 0c2ab0e..40b9793 100644 --- a/aprsd/cmds/listen.py +++ b/aprsd/cmds/listen.py @@ -104,13 +104,18 @@ class ListenStatsThread(APRSDThread): stats_json = collector.Collector().collect() stats = stats_json["PacketList"] total_rx = stats["rx"] - rate = (total_rx - self._last_total_rx) / 10 + rx_delta = total_rx - self._last_total_rx + rate = rx_delta / 10 + + # Log summary stats LOGU.opt(colors=True).info( f"RX Rate: {rate} pps " f"Total RX: {total_rx} " - f"RX Last 10 secs: {total_rx - self._last_total_rx}", + f"RX Last 10 secs: {rx_delta}", ) self._last_total_rx = total_rx + + # Log individual type stats for k, v in stats["types"].items(): thread_hex = f"fg {utils.hex_from_name(k)}" LOGU.opt(colors=True).info(