Skip to content
Snippets Groups Projects
Commit 4a6a9070 authored by Henning Glawe's avatar Henning Glawe
Browse files

build global match statistics via SimpleParser.updateTelemetryCounters

parent 013ba957
Branches
Tags
No related merge requests found
......@@ -20,9 +20,6 @@ class Annotator(object):
self._formatNameWidth = formatNameWidth
self._formatSourceWidth = formatSourceWidth
self._update_annotate_format()
self.counter = {}
for counter in ['total', 'ignore', 'match', 'partial', 'unmatched']:
self.counter[counter] = 0
def _update_annotate_format(self):
self._annotate_format = '%%%ds:%%04d %%%ds %%9s|%%s' % (
......@@ -37,17 +34,6 @@ class Annotator(object):
self._update_annotate_format()
def annotate(self, minfo):
# update counters
self.counter['total'] += 1
if minfo['coverageIgnore']:
self.counter['ignore'] += 1
elif minfo['match'] > 1:
self.counter['match'] += 1
elif minfo['match']:
self.counter['partial'] += 1
else:
self.counter['unmatched'] += 1
# don't write to file unless it is there
if not self.annotateFile:
return 1
......
......@@ -738,6 +738,7 @@ class CompiledMatcher(object):
def handleMatchTelemetry(self, parser, match, line, targetStartEnd):
match_telemetry = self.getMatchTelemetry(parser, match, line, targetStartEnd)
parser.updateTelemetryCounters(match_telemetry)
parser.annotator.annotate(match_telemetry)
class ParsingContext(object): # use slots?
......@@ -1047,6 +1048,9 @@ class SimpleParser(object):
# by default, ignore empty lines in coverage analysis
self.coverageIgnore = getattr(superContext, 'coverageIgnore',
re.compile(r"^\s*$"))
self.telemetry_counter = {}
for counter in ['total', 'ignore', 'match', 'partial', 'unmatched']:
self.telemetry_counter[counter] = 0
if annotate:
annofilename=fIn.fIn.name + ".annotate"
else:
......@@ -1144,6 +1148,19 @@ class SimpleParser(object):
while self.parseStep():
pass
def updateTelemetryCounters(self, matchTelemetry):
# update counters
self.telemetry_counter['total'] += 1
if matchTelemetry['coverageIgnore']:
self.telemetry_counter['ignore'] += 1
elif matchTelemetry['match'] > 1:
self.telemetry_counter['match'] += 1
elif matchTelemetry['match']:
self.telemetry_counter['partial'] += 1
else:
self.telemetry_counter['unmatched'] += 1
def compileParser(simpleParser, metaInfo, metaInfoToKeep, default_units=None, metainfo_units=None, strValueTransform=None):
"""compiles the given simple parser"""
parserBuilder = SimpleParserBuilder(simpleParser, metaInfo, metaInfoToKeep, default_units, metainfo_units, strValueTransform)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment