rts_metrics.py (1167B)
1 """Whole-process GHC -s statistics; never conflate these with invocation deltas.""" 2 import re 3 4 5 def parse_rts_stats(output): 6 fields = {} 7 for label, key in [('allocated in the heap', 'allocated_bytes'), 8 ('copied during GC', 'copied_bytes'), 9 ('maximum residency', 'maximum_live_bytes')]: 10 found = re.search(r'^[ \t]*([0-9,]+) bytes ' + label, output, re.M) 11 if found: 12 fields[key] = int(found[1].replace(',', '')) 13 for label, key in [('MUT', 'mutator'), ('GC', 'gc')]: 14 found = re.search(r'^\s*' + label + r'\s+time\s+([0-9.]+)s\s+\(\s*([0-9.]+)s elapsed\)', output, re.M) 15 if found: 16 fields[key + '_cpu_seconds'] = float(found[1]) 17 fields[key + '_elapsed_seconds'] = float(found[2]) 18 found = re.search(r'Productivity\s+([0-9.]+)% of total user,\s+([0-9.]+)% of total elapsed', output) 19 if found: 20 fields['productivity_cpu_percent'] = float(found[1]) 21 fields['productivity_elapsed_percent'] = float(found[2]) 22 if fields: 23 fields['measurement_scope'] = 'whole-process-including-load-render-and-sampling' 24 return fields