add recvplotdiff

This commit is contained in:
flandre 2025-05-13 22:04:30 +08:00
parent 680ea99b6b
commit d018e1cf1a

View File

@ -233,12 +233,35 @@ def device_recvplot():
last_ts = ts last_ts = ts
first = False first = False
continue continue
print((ts - last_ts)/10**6,flush=True) print((ts - last_ts) / 10 ** 6, flush=True)
last_ts = ts last_ts = ts
@device.command('recvplotdiff')
def device_recvplotdiff():
ctx = zmq.Context()
pull = ctx.socket(zmq.PULL)
pull.connect(C.live_push_socket)
last_ts = 0
max_interval = 0
first = True
while True:
b = pull.recv()
ts, sequence_id, encoder, buffer = b2t(b)
if first:
last_ts = ts
first = False
continue
max_interval = max(max_interval, ts - last_ts)
print(max_interval / 10 ** 6, flush=True)
last_ts = ts
def b2b(b): def b2b(b):
return hashlib.blake2b(b, digest_size=4).hexdigest() return hashlib.blake2b(b, digest_size=4).hexdigest()
@device.command('recvzero') @device.command('recvzero')
def device_recvzero(): def device_recvzero():
ctx = zmq.Context() ctx = zmq.Context()
@ -251,12 +274,12 @@ def device_recvzero():
while True: while True:
b = pull.recv() b = pull.recv()
ts, sequence_id, encoder, buffer = b2t(b) ts, sequence_id, encoder, buffer = b2t(b)
if ts==last_ts: if ts == last_ts:
print('tszero', sequence_id, encoder, (ts - last_ts)/10**6,flush=True) print('tszero', sequence_id, encoder, (ts - last_ts) / 10 ** 6, flush=True)
print(b2b(b),b2b(last_b)) print(b2b(b), b2b(last_b))
if sequence_id==last_sequence_id: if sequence_id == last_sequence_id:
print('szero', sequence_id, encoder,flush=True) print('szero', sequence_id, encoder, flush=True)
print(b2b(b),b2b(last_b)) print(b2b(b), b2b(last_b))
last_ts = ts last_ts = ts
last_sequence_id = sequence_id last_sequence_id = sequence_id
last_b = b last_b = b