tracer: stats: python style cleanup

This commit is contained in:
Stefan Sauer 2017-02-05 19:37:07 +01:00
parent 1cebf3a24f
commit bb3bff3659

View file

@ -10,24 +10,23 @@ python3 gsttr-stats.py trace.log
3) print selected entries only
python3 gsttr-stats.py -c latency trace.log
'''
import logging
from fnmatch import fnmatch
# TODO:
# more options
# - live-update interval (for file=='-')
#
# - for values like timestamps, we only want min/max but no average
logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger('gsttr-stats')
import logging
from fnmatch import fnmatch
from tracer.analysis_runner import AnalysisRunner
from tracer.analyzer import Analyzer
from tracer.parser import Parser
from tracer.structure import Structure
logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger('gsttr-stats')
_SCOPE_RELATED_TO = {
'GST_TRACER_VALUE_SCOPE_PAD': 'Pad',
'GST_TRACER_VALUE_SCOPE_ELEMENT': 'Element',
@ -37,6 +36,7 @@ _SCOPE_RELATED_TO = {
_NUMERIC_TYPES = ('int', 'uint', 'gint', 'guint', 'gint64', 'guint64')
class Stats(Analyzer):
def __init__(self, classes):
@ -164,6 +164,7 @@ class Stats(Analyzer):
avg = format_ts(avg)
print("%-45s: %30s: %16s/%16s/%16s" % (sk, tk, mi, avg, ma))
class ListClasses(Analyzer):
def __init__(self):
@ -182,13 +183,15 @@ def format_ts(ts):
h = int(ts // (sec * 60 * 60))
m = int((ts // (sec * 60)) % 60)
s = (ts / sec)
return '{:02d}:{:02d}:{:010.7f}'.format(h,m,s)
return '{:02d}:{:02d}:{:010.7f}'.format(h, m, s)
def is_time_field(f):
# TODO: need proper units
return (f.endswith('/time') or f.endswith('-dts') or f.endswith('-pts') or
f.endswith('-duration'))
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()