diff options
author | _VIFEXTech <vifextech@foxmail.com> | 2023-06-05 22:53:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-05 16:53:57 +0200 |
commit | 06b3b624755b04913b78b3b367b183c02abc9348 (patch) | |
tree | 2dd36bf40b291ff325dfbd6eddc822f4a3ba4386 /scripts/trace_filter.py | |
parent | 93f4b90393ef86ed38a0a7743d562b4d8e20b972 (diff) | |
download | lvgl-06b3b624755b04913b78b3b367b183c02abc9348.tar.gz lvgl-06b3b624755b04913b78b3b367b183c02abc9348.zip |
feat(profiler): add built-in profiler (#4255)
Signed-off-by: FASTSHIFT <vifextech@foxmail.com>
Co-authored-by: W-Mai <1341398182@qq.com>
Diffstat (limited to 'scripts/trace_filter.py')
-rwxr-xr-x | scripts/trace_filter.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/scripts/trace_filter.py b/scripts/trace_filter.py new file mode 100755 index 000000000..5fbf51db4 --- /dev/null +++ b/scripts/trace_filter.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +import argparse +import re + +MARK_LIST = ['tracing_mark_write'] + + +def get_arg(): + parser = argparse.ArgumentParser(description='Filter a log file to a trace file.') + parser.add_argument('log_file', metavar='log_file', type=str, + help='The input log file to process.') + parser.add_argument('trace_file', metavar='trace_file', type=str, nargs='?', default='trace.systrace', + help='The output trace file. If not provided, defaults to \'trace.systrace\'.') + + args = parser.parse_args() + + print('log_file: ' + args.log_file) + print('trace_file: ' + args.trace_file) + + return args + + +if __name__ == '__main__': + args = get_arg() + + with open(args.log_file, 'r') as f: + content = f.read() + + # compile regex pattern + pattern = re.compile(r'(^.+-[0-9]+\s\[[0-9]]\s[0-9]+\.[0-9]+:\s(' + + "|".join(MARK_LIST) + + r'):\s[B|E]\|[0-9]+\|.+$)', re.M) + + matches = pattern.findall(content) + + # write to args.trace_file + with open(args.trace_file, 'w') as f: + f.write('# tracer: nop\n#\n') + for match in matches: + f.write(match[0] + '\n') |