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