History

gen_compile_commands: parse only the first line of .*.cmd files

After the allmodconfig build, this script takes about 5 sec on my machine. Most of the run-time is consumed for needless regex matching. We know the format of .*.cmd file; the first line is the build command. There is no need to parse the rest. With this optimization, now it runs 4 times faster.

Masahiro Yamada committed 6 years ago

Commit 8a685db1 parent 23cd88c1 file · +2 −5Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/gen_compile_commands.py+2−5
@@ -125,11 +125,8 @@ def main(): · 124 unmodified lines
125 filepath = os.path.join(dirpath, filename)125 filepath = os.path.join(dirpath, filename)
126 126
127 with open(filepath, 'rt') as f:127 with open(filepath, 'rt') as f:
128 for line in f:128 result = line_matcher.match(f.readline())
129 result = line_matcher.match(line)129 if result:
130 if not result:
131 continue
132
133 try:130 try:
134 entry = process_line(directory, dirpath,131 entry = process_line(directory, dirpath,
135 result.group(1), result.group(2))132 result.group(1), result.group(2))