27parser = argparse.ArgumentParser()
30 help=
"X-macro output file. "
31 "If it exists, existing contents will be used for hysteresis",
32 default=
"clang-tools-extra/clangd/TidyFastChecks.inc",
36 help=
"Source file to benchmark tidy checks",
37 default=
"clang/lib/Sema/Sema.cpp",
40 "--clangd", help=
"clangd binary to invoke", default=
"build/bin/clangd"
42parser.add_argument(
"--checks", help=
"check glob to run", default=
"*")
43parser.add_argument(
"--verbose", help=
"log clangd output", action=
"store_true")
44args = parser.parse_args()
48 text = subprocess.check_output(
57 for line
in text.splitlines():
59 yield line.strip().decode(
"utf-8")
62old_fast = list(
read_old_fast(args.target))
if os.path.exists(args.target)
else []
63print(f
"Old fast checks: {old_fast}", file=sys.stderr)
68 process = subprocess.Popen(
71 "--check=" + args.source,
72 "--check-locations=0",
73 "--check-tidy-time=" + args.checks,
75 stderr=subprocess.PIPE,
78 for line
in iter(process.stderr.readline, b
""):
80 print(
"clangd> ", line, file=sys.stderr)
82 if b
"Timing AST build with individual clang-tidy checks" in line:
85 if b
"Finished individual clang-tidy checks" in line:
87 match = re.search(rb
"(\S+) = (\S+)%", line)
89 yield (match.group(1).decode(
"utf-8"), float(match.group(2)))
92with open(args.target,
"w", buffering=1)
as target:
95 f
"""// This file is generated, do not edit it directly!
96// Deltas are percentage regression in parsing {args.source}
98#define FAST(CHECK, DELTA)
101#define SLOW(CHECK, DELTA)
108 threshold = SLOW_THRESHOLD
if check
in old_fast
else FAST_THRESHOLD
109 decision =
"FAST" if time <= threshold
else "SLOW"
110 print(f
"{decision} {check} {time}% <= {threshold}%", file=sys.stderr)
111 print(f
"{decision}({check}, {time})", file=target)