Skip to content

Commit

Permalink
Fix top latency measurements with stddev
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmoreno committed Dec 15, 2023
1 parent 91c55a7 commit 43bdf05
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cli/rtpmidid-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def __init__(self, filename):
self.socket.connect(filename)
except ConnectionRefusedError:
print(
"Connection refused to %s. Change control socket location with RTPMIDID_SOCKET environment var."
"Connection refused to %s. Can set other location with --control=<path>"
% filename
)
raise
sys.exit(1)

def command(self, command):
self.socket.send(json.dumps(command).encode("utf8") + b"\n")
Expand Down Expand Up @@ -126,6 +126,14 @@ def getter(data):
return getter


def latency_getter(data):
avg = safe_getter("peer", "latency_ms", "average")(data)
if not avg:
return ""
stddev = safe_getter("peer", "latency_ms", "stddev")(data)
return f"{avg}ms \u00B1 {stddev}ms"


COLUMNS = [
{
"name": "ID",
Expand Down Expand Up @@ -165,8 +173,9 @@ def getter(data):
},
{
"name": "Latency",
"get": lambda x: f'{safe_getter("peer", "latency_ms")(x)}ms',
"width": 8,
# the unicode symbol for +- is \u00B1
"get": latency_getter,
"width": 20,
"align": "right",
},
{
Expand Down

0 comments on commit 43bdf05

Please sign in to comment.