From 33874a8f71364cc99d6d67636cbd6ddff8e202e2 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Thu, 20 Jul 2017 11:01:14 +0100 Subject: [PATCH] utils/trace_cmd: reduce regex use Do not attempt to regex match each line for dropped events/preamble. Use substring search to detect them first, and only use regex on relevant lines. --- wlauto/utils/trace_cmd.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/wlauto/utils/trace_cmd.py b/wlauto/utils/trace_cmd.py index c2b655ce..77556b35 100644 --- a/wlauto/utils/trace_cmd.py +++ b/wlauto/utils/trace_cmd.py @@ -274,20 +274,23 @@ class TraceCmdTrace(object): elif TRACE_MARKER_STOP in line: break - match = DROPPED_EVENTS_REGEX.search(line) - if match: - yield DroppedEventsEvent(match.group('cpu_id')) - continue - - matched = False - for rx in [HEADER_REGEX, EMPTY_CPU_REGEX]: - match = rx.search(line) + if 'EVENTS DROPPED' in line: + match = DROPPED_EVENTS_REGEX.search(line) if match: - logger.debug(line.strip()) - matched = True - break - if matched: - continue + yield DroppedEventsEvent(match.group('cpu_id')) + continue + + if line.startswith('version') or line.startswith('cpus') or\ + line.startswith('CPU:'): + matched = False + for rx in [HEADER_REGEX, EMPTY_CPU_REGEX]: + match = rx.search(line) + if match: + logger.debug(line.strip()) + matched = True + break + if matched: + continue # : : parts = line.split(': ', 2)