profile cumulative time for all NACs
This commit is contained in:
parent
38e120e6c8
commit
b6a654580c
1 changed files with 28 additions and 30 deletions
|
|
@ -50,38 +50,36 @@ class RuleMatcherRewriter:
|
||||||
|
|
||||||
nac_matched = False
|
nac_matched = False
|
||||||
|
|
||||||
try:
|
with Timer(f"MATCH NACs {rule_name}"):
|
||||||
for i_nac, nac in enumerate(nacs):
|
try:
|
||||||
# For every LHS-match, we see if there is a NAC-match:
|
for i_nac, nac in enumerate(nacs):
|
||||||
nac_matcher = match_od(self.state,
|
# For every LHS-match, we see if there is a NAC-match:
|
||||||
host_m=m,
|
nac_matcher = match_od(self.state,
|
||||||
host_mm=self.mm,
|
host_m=m,
|
||||||
pattern_m=nac,
|
host_mm=self.mm,
|
||||||
pattern_mm=self.mm_ramified,
|
pattern_m=nac,
|
||||||
pivot=lhs_match) # try to "grow" LHS-match with NAC-match
|
pattern_mm=self.mm_ramified,
|
||||||
|
pivot=lhs_match) # try to "grow" LHS-match with NAC-match
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# for nac_match in nac_matcher:
|
# for nac_match in nac_matcher:
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
with Timer(f"MATCH NAC{i_nac} {rule_name}"):
|
with Timer(f"MATCH NAC{i_nac} {rule_name}"):
|
||||||
nac_match = nac_matcher.__next__()
|
nac_match = nac_matcher.__next__()
|
||||||
|
# The NAC has at least one match
|
||||||
|
# (there could be more, but we know enough, so let's not waste CPU/MEM resources and proceed to next LHS match)
|
||||||
|
raise _NAC_MATCHED()
|
||||||
|
except StopIteration:
|
||||||
|
break # no more nac-matches
|
||||||
|
|
||||||
raise _NAC_MATCHED()
|
except Exception as e:
|
||||||
except StopIteration:
|
# The exception may originate from eval'ed condition-code in LHS or NAC
|
||||||
break # no more nac-matches
|
# Decorate exception with some context, to help with debugging
|
||||||
|
e.add_note(f"while matching NAC of '{rule_name}'")
|
||||||
# The NAC has at least one match
|
raise
|
||||||
# (there could be more, but we know enough, so let's not waste CPU/MEM resources and proceed to next LHS match)
|
except _NAC_MATCHED:
|
||||||
nac_matched = True
|
continue # continue with next LHS-match
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
# The exception may originate from eval'ed condition-code in LHS or NAC
|
|
||||||
# Decorate exception with some context, to help with debugging
|
|
||||||
e.add_note(f"while matching NAC of '{rule_name}'")
|
|
||||||
raise
|
|
||||||
except _NAC_MATCHED:
|
|
||||||
continue # continue with next LHS-match
|
|
||||||
|
|
||||||
# There were no NAC matches -> yield LHS-match!
|
# There were no NAC matches -> yield LHS-match!
|
||||||
yield lhs_match
|
yield lhs_match
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue