mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-16 21:36:35 +00:00
8ca9bda671
Original commit message from CVS: 2005-06-28 Andy Wingo <wingo@pobox.com> * tests/network-clock-utils.scm (debug, print-event): New utils. * tests/network-clock.scm (*debug*, *with-graph*): New parameters. (*packet-loss*): Unified loss probability. (network-time): Report out-of-band events. * tests/plot-data: Add support for out-of-band events. Hack it into this script instead of passing it down the pipe; should fix this later.
81 lines
2.4 KiB
Python
Executable file
81 lines
2.4 KiB
Python
Executable file
#!/usr/bin/env python
|
|
|
|
from __future__ import division
|
|
|
|
import pylab
|
|
import optparse
|
|
import sys
|
|
|
|
def parse_data(l, state):
|
|
state['data'].append([float(x) for x in filter(None, l.split(' '))])
|
|
return state
|
|
|
|
def parse_event(l, state):
|
|
components = filter(None, l.split(' '))
|
|
vals = [float(x) for x in components[1:]]
|
|
if not components[0] in state:
|
|
state[components[0]] = [vals]
|
|
else:
|
|
state[components[0]].append(vals)
|
|
return state
|
|
|
|
def read_line(fd, state):
|
|
l = fd.readline()
|
|
if not l:
|
|
return None
|
|
l = l.strip()
|
|
if l[0].isdigit():
|
|
return parse_data(l, state)
|
|
else:
|
|
return parse_event(l, state)
|
|
|
|
def read_data(fd):
|
|
state = {'data':[],
|
|
'packet-sent':[],
|
|
'packet-lost':[],
|
|
'packet-received':[],
|
|
'packet-observed':[]}
|
|
newstate = state
|
|
while newstate:
|
|
state = newstate
|
|
newstate = read_line(fd, state)
|
|
return state
|
|
|
|
def make_xticks(start, end, numticks):
|
|
return range(int(start), int(end), int((start-end)/numticks))
|
|
|
|
def make_plot(title):
|
|
l = sys.stdin.readline()
|
|
labels = l.strip().split(';')
|
|
state = read_data(sys.stdin)
|
|
data = state['data']
|
|
lost_packets = state['packet-lost']
|
|
obsv_packets = state['packet-observed']
|
|
sent_packets = state['packet-sent']
|
|
recd_packets = state['packet-received']
|
|
|
|
domain = [x[0] for x in data]
|
|
for i in range(1,len(labels)):
|
|
pylab.plot(domain, [x[i] for x in data], label=labels[i])
|
|
pylab.plot([x[0] for x in lost_packets], [x[1] for x in lost_packets],
|
|
label='Client sent packet, but dropped', marker='x', linestyle=None, ms=8)
|
|
pylab.plot([x[0] for x in sent_packets], [x[1] for x in sent_packets],
|
|
label='Client sent packet', marker='^', linestyle=None, ms=8)
|
|
pylab.plot([x[0] for x in obsv_packets], [x[1] for x in obsv_packets],
|
|
label='Remote time observation', marker='D', linestyle=None, ms=8)
|
|
pylab.plot([x[0] for x in recd_packets], [x[1] for x in recd_packets],
|
|
label='Client received packet', marker='v', linestyle=None, ms=8)
|
|
pylab.legend()
|
|
pylab.ylabel(r'Clock time (s)')
|
|
pylab.xlabel(r'Real time (s)')
|
|
pylab.title(title)
|
|
pylab.grid(True)
|
|
pylab.show()
|
|
|
|
def main(args):
|
|
parser = optparse.OptionParser()
|
|
|
|
title = ' '.join(args[1:])
|
|
make_plot(title)
|
|
|
|
main(sys.argv)
|