lkml.org 
[lkml]   [2020]   [Aug]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/3] gen_compile_commands: parse only the first line of .*.cmd files
Date
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 remaining.

With this optimization, now it runs in about 1 sec with the allmodconfig
build.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

scripts/gen_compile_commands.py | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py
index c458696ef3a7..19c7338740e7 100755
--- a/scripts/gen_compile_commands.py
+++ b/scripts/gen_compile_commands.py
@@ -125,11 +125,9 @@ def main():
filepath = os.path.join(dirpath, filename)

with open(filepath, 'rt') as f:
- for line in f:
- result = line_matcher.match(line)
- if not result:
- continue
-
+ line = f.readline()
+ result = line_matcher.match(line)
+ if result:
try:
entry = process_line(directory, dirpath,
result.group(1), result.group(2))
--
2.25.1
\
 
 \ /
  Last update: 2020-08-12 19:43    [W:0.098 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site