mirror of
https://github.com/mpv-player/mpv
synced 2024-08-04 14:59:58 +02:00
TOOLS/stats-conv: more improvements
Add an explicit "signal" event type, because the implicit one was confusing. Don't rescale the Y axis of the second graph, it was nonsense. Make the legend for the second graph separate (and cleanup the code creating the graphs).
This commit is contained in:
parent
6a6620a554
commit
73ea0ddc08
@ -21,13 +21,14 @@ e.g.:
|
|||||||
|
|
||||||
Currently, the following event types are supported:
|
Currently, the following event types are supported:
|
||||||
|
|
||||||
|
'signal' <name> singular event
|
||||||
'start' <name> start of the named event
|
'start' <name> start of the named event
|
||||||
'end' <name> end of the named event
|
'end' <name> end of the named event
|
||||||
'value' <float> <name> a normal value (as opposed to event)
|
'value' <float> <name> a normal value (as opposed to event)
|
||||||
'event-timed' <ts> <name> singular event at the given timestamp
|
'event-timed' <ts> <name> singular event at the given timestamp
|
||||||
'value-timed' <ts> <float> <name>
|
'value-timed' <ts> <float> <name>
|
||||||
a value for an event at the given timestamp
|
a value for an event at the given timestamp
|
||||||
<name> singular event
|
<name> singular event (same as 'signal')
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -94,6 +95,10 @@ for line in [line.split("#")[0].strip() for line in open(filename, "r")]:
|
|||||||
val = float(val)
|
val = float(val)
|
||||||
e = get_event(name, "value")
|
e = get_event(name, "value")
|
||||||
e.vals.append((tsval, val))
|
e.vals.append((tsval, val))
|
||||||
|
elif event.startswith("signal "):
|
||||||
|
name = event.split(" ", 2)[1]
|
||||||
|
e = get_event(name, "event-signal")
|
||||||
|
e.vals.append((ts, 1))
|
||||||
else:
|
else:
|
||||||
e = get_event(event, "event-signal")
|
e = get_event(event, "event-signal")
|
||||||
e.vals.append((ts, 1))
|
e.vals.append((ts, 1))
|
||||||
@ -104,23 +109,25 @@ G.sevents.sort(key=lambda x: x.name)
|
|||||||
hasval = False
|
hasval = False
|
||||||
for e, index in zip(G.sevents, range(len(G.sevents))):
|
for e, index in zip(G.sevents, range(len(G.sevents))):
|
||||||
m = len(G.sevents)
|
m = len(G.sevents)
|
||||||
e.vals = [(x, y * (m - index) / m) for (x, y) in e.vals]
|
|
||||||
if e.type == "value":
|
if e.type == "value":
|
||||||
hasval = True
|
hasval = True
|
||||||
|
|
||||||
plot.hold(True)
|
|
||||||
plots = 2 if hasval else 1
|
|
||||||
mainpl = plot.subplot(plots, 1, 1)
|
|
||||||
legend = []
|
|
||||||
for e in G.sevents:
|
|
||||||
if e.type == "value":
|
|
||||||
plot.subplot(plots, 1, 2, sharex=mainpl)
|
|
||||||
else:
|
else:
|
||||||
plot.subplot(plots, 1, 1)
|
e.vals = [(x, y * (m - index) / m) for (x, y) in e.vals]
|
||||||
pl, = plot.plot([x for x,y in e.vals], [y for x,y in e.vals], label=e.name)
|
|
||||||
|
fig = plot.figure()
|
||||||
|
fig.hold(True)
|
||||||
|
ax = [None, None]
|
||||||
|
plots = 2 if hasval else 1
|
||||||
|
ax[0] = fig.add_subplot(plots, 1, 1)
|
||||||
|
if hasval:
|
||||||
|
ax[1] = fig.add_subplot(plots, 1, 2, sharex=ax[0])
|
||||||
|
legends = [[], []]
|
||||||
|
for e in G.sevents:
|
||||||
|
cur = ax[1 if e.type == "value" else 0]
|
||||||
|
pl, = cur.plot([x for x,y in e.vals], [y for x,y in e.vals], label=e.name)
|
||||||
if e.type == "event-signal":
|
if e.type == "event-signal":
|
||||||
plot.setp(pl, marker = e.marker, linestyle = "None")
|
plot.setp(pl, marker = e.marker, linestyle = "None")
|
||||||
legend.append(pl)
|
for cur in ax:
|
||||||
plot.subplot(plots, 1, 1)
|
if cur is not None:
|
||||||
plot.legend(legend, [pl.get_label() for pl in legend])
|
cur.legend()
|
||||||
plot.show()
|
plot.show()
|
||||||
|
Loading…
Reference in New Issue
Block a user