mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
tracer: add a first tool to report aggregated findings
A tool to report min/max/avg values per scope and traced value.
This commit is contained in:
parent
896201af35
commit
a066c2f332
1 changed files with 43 additions and 0 deletions
43
tracer/gsttr-stats.py
Normal file
43
tracer/gsttr-stats.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
'''
|
||||||
|
How to run:
|
||||||
|
Offline:
|
||||||
|
GST_DEBUG="GST_TRACER:7" GST_TRACERS="stats;rusage;latency" GST_DEBUG_FILE=trace.log <application>
|
||||||
|
python3 gsttr-stats.py trace.log
|
||||||
|
'''
|
||||||
|
|
||||||
|
from tracer.analyzer import Analyzer
|
||||||
|
from tracer.parser import Parser
|
||||||
|
|
||||||
|
def format_ts(ts):
|
||||||
|
sec = 1e9
|
||||||
|
h = int(ts // (sec * 60 * 60))
|
||||||
|
m = int((ts // (sec * 60)) % 60)
|
||||||
|
s = (ts / sec)
|
||||||
|
return '{:02d}.{:02d}.{:010.7f}'.format(h,m,s)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import argparse
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('file', nargs='?', default='debug.log')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
with Parser(args.file) as log:
|
||||||
|
stats = Analyzer(log)
|
||||||
|
stats.run()
|
||||||
|
|
||||||
|
# iterate scopes
|
||||||
|
for sk,sv in stats.data.items():
|
||||||
|
# iterate tracers
|
||||||
|
for tk,tv in sv.items():
|
||||||
|
mi = tv.get('min', '-')
|
||||||
|
ma = tv.get('max', '-')
|
||||||
|
avg = tv['sum']/tv['num']
|
||||||
|
# TODO: need proper units
|
||||||
|
if tk.endswith('/time') or tk.endswith('-dts') or tk.endswith('-pts'):
|
||||||
|
if mi != '-':
|
||||||
|
mi = format_ts(mi)
|
||||||
|
if ma != '-':
|
||||||
|
ma = format_ts(ma)
|
||||||
|
avg = format_ts(avg)
|
||||||
|
print("%-45s: Min/Avg,Max %30s: %s, %s, %s" % (sk, tk, mi, avg, ma))
|
Loading…
Reference in a new issue