mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-17 22:06:41 +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
|
record['scope'][k] = v
|
||||||
elif v.name == 'value':
|
elif v.name == 'value':
|
||||||
# skip non numeric and those without min/max
|
# 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
|
if (v.values['type'] in _NUMERIC_TYPES and
|
||||||
'min' in v.values and 'max' in v.values):
|
'min' in v.values and 'max' in v.values):
|
||||||
# TODO only for debugging
|
# TODO only for debugging
|
||||||
|
@ -113,22 +111,28 @@ class Stats(Analyzer):
|
||||||
key = entry_name + "/" + vk
|
key = entry_name + "/" + vk
|
||||||
data = scope.get(key)
|
data = scope.get(key)
|
||||||
if not data:
|
if not data:
|
||||||
data = {
|
data = { 'num': 0 }
|
||||||
'num': 0,
|
if not '_FLAGS_AGGREGATED' in vv.values.get('flags', ''):
|
||||||
'sum': 0,
|
data['sum'] = 0
|
||||||
}
|
if 'max' in vv.values and 'min' in vv.values:
|
||||||
if 'max' in vv.values and 'min' in vv.values:
|
data['min'] = int(vv.values['max'])
|
||||||
data['min'] = int(vv.values['max'])
|
data['max'] = int(vv.values['min'])
|
||||||
data['max'] = int(vv.values['min'])
|
else:
|
||||||
|
# aggregated: don't average, collect first value
|
||||||
|
data['min'] = int(s.values[vk])
|
||||||
scope[key] = data
|
scope[key] = data
|
||||||
# update min/max/sum and count via value
|
# update min/max/sum and count via value
|
||||||
dv = int(s.values[vk])
|
dv = int(s.values[vk])
|
||||||
data['num'] += 1
|
data['num'] += 1
|
||||||
data['sum'] += dv
|
if 'sum' in data:
|
||||||
if 'min' in data:
|
data['sum'] += dv
|
||||||
data['min'] = min(dv, data['min'])
|
if 'min' in data:
|
||||||
if 'max' in data:
|
data['min'] = min(dv, data['min'])
|
||||||
data['max'] = max(dv, data['max'])
|
if 'max' in data:
|
||||||
|
data['max'] = max(dv, data['max'])
|
||||||
|
else:
|
||||||
|
# aggregated: collect last value
|
||||||
|
data['max'] = dv
|
||||||
|
|
||||||
def report(self):
|
def report(self):
|
||||||
# headline
|
# headline
|
||||||
|
@ -140,7 +144,10 @@ class Stats(Analyzer):
|
||||||
for tk,tv in sv.items():
|
for tk,tv in sv.items():
|
||||||
mi = tv.get('min', '-')
|
mi = tv.get('min', '-')
|
||||||
ma = tv.get('max', '-')
|
ma = tv.get('max', '-')
|
||||||
avg = tv['sum']/tv['num']
|
if 'sum' in tv:
|
||||||
|
avg = tv['sum']/tv['num']
|
||||||
|
else:
|
||||||
|
avg = '-'
|
||||||
if mi == ma:
|
if mi == ma:
|
||||||
mi = ma = '-'
|
mi = ma = '-'
|
||||||
if is_time_field(tk):
|
if is_time_field(tk):
|
||||||
|
@ -148,7 +155,8 @@ class Stats(Analyzer):
|
||||||
mi = format_ts(mi)
|
mi = format_ts(mi)
|
||||||
if ma != '-':
|
if ma != '-':
|
||||||
ma = format_ts(ma)
|
ma = format_ts(ma)
|
||||||
avg = format_ts(avg)
|
if avg != '-':
|
||||||
|
avg = format_ts(avg)
|
||||||
print("%-45s: %30s: %16s/%16s/%16s" % (sk, tk, mi, avg, ma))
|
print("%-45s: %30s: %16s/%16s/%16s" % (sk, tk, mi, avg, ma))
|
||||||
|
|
||||||
class ListClasses(Analyzer):
|
class ListClasses(Analyzer):
|
||||||
|
|
Loading…
Reference in a new issue