tracer/gsttr-stats: move time unit hack into method
authorStefan Sauer <ensonic@users.sf.net>
Wed, 14 Dec 2016 20:28:12 +0000 (21:28 +0100)
committerStefan Sauer <ensonic@users.sf.net>
Tue, 20 Dec 2016 07:24:57 +0000 (08:24 +0100)
tracer/gsttr-stats.py

index fb434c9..3406e78 100644 (file)
@@ -108,6 +108,11 @@ def format_ts(ts):
     s = (ts / sec)
     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()
@@ -127,8 +132,7 @@ if __name__ == '__main__':
             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 is_time_field(tk):
                 if mi != '-':
                     mi = format_ts(mi)
                 if ma != '-':