Skip to content

Commit

Permalink
Calculate delta once and reuse it
Browse files Browse the repository at this point in the history
  • Loading branch information
hemna committed Nov 5, 2024
1 parent d808e21 commit 0be87d8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions aprsd/cmds/listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,18 @@ def loop(self):
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"<green>RX Rate: {rate} pps</green> "
f"<yellow>Total RX: {total_rx}</yellow> "
f"<red>RX Last 10 secs: {total_rx - self._last_total_rx}</red>",
f"<red>RX Last 10 secs: {rx_delta}</red>",
)
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(
Expand Down

0 comments on commit 0be87d8

Please sign in to comment.