mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
tracer: gsttr-stats: don't average aggregated values
Only collect the first/last values for them.
This commit is contained in:
parent
4771b445e9
commit
013b747404
1 changed files with 24 additions and 16 deletions
|
@ -63,8 +63,6 @@ class Stats(Analyzer):
|
|||
record['scope'][k] = v
|
||||
elif v.name == 'value':
|
||||
# skip non numeric and those without min/max
|
||||
# TODO: skip them only if flags != AGGREGATED
|
||||
# - if flag is AGGREGATED, don't calc average
|
||||
if (v.values['type'] in _NUMERIC_TYPES and
|
||||
'min' in v.values and 'max' in v.values):
|
||||
# TODO only for debugging
|
||||
|
@ -113,22 +111,28 @@ class Stats(Analyzer):
|
|||
key = entry_name + "/" + vk
|
||||
data = scope.get(key)
|
||||
if not data:
|
||||
data = {
|
||||
'num': 0,
|
||||
'sum': 0,
|
||||
}
|
||||
data = { 'num': 0 }
|
||||
if not '_FLAGS_AGGREGATED' in vv.values.get('flags', ''):
|
||||
data['sum'] = 0
|
||||
if 'max' in vv.values and 'min' in vv.values:
|
||||
data['min'] = int(vv.values['max'])
|
||||
data['max'] = int(vv.values['min'])
|
||||
else:
|
||||
# aggregated: don't average, collect first value
|
||||
data['min'] = int(s.values[vk])
|
||||
scope[key] = data
|
||||
# update min/max/sum and count via value
|
||||
dv = int(s.values[vk])
|
||||
data['num'] += 1
|
||||
if 'sum' in data:
|
||||
data['sum'] += dv
|
||||
if 'min' in data:
|
||||
data['min'] = min(dv, data['min'])
|
||||
if 'max' in data:
|
||||
data['max'] = max(dv, data['max'])
|
||||
else:
|
||||
# aggregated: collect last value
|
||||
data['max'] = dv
|
||||
|
||||
def report(self):
|
||||
# headline
|
||||
|
@ -140,7 +144,10 @@ class Stats(Analyzer):
|
|||
for tk,tv in sv.items():
|
||||
mi = tv.get('min', '-')
|
||||
ma = tv.get('max', '-')
|
||||
if 'sum' in tv:
|
||||
avg = tv['sum']/tv['num']
|
||||
else:
|
||||
avg = '-'
|
||||
if mi == ma:
|
||||
mi = ma = '-'
|
||||
if is_time_field(tk):
|
||||
|
@ -148,6 +155,7 @@ class Stats(Analyzer):
|
|||
mi = format_ts(mi)
|
||||
if ma != '-':
|
||||
ma = format_ts(ma)
|
||||
if avg != '-':
|
||||
avg = format_ts(avg)
|
||||
print("%-45s: %30s: %16s/%16s/%16s" % (sk, tk, mi, avg, ma))
|
||||
|
||||
|
|
Loading…
Reference in a new issue