[clang-tools-extra] [clang-tidy] Add 'enable-check-profiling' with aggregated results to 'run-clang-tidy' (PR #151011)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 28 22:02:59 PDT 2025


================
@@ -178,6 +182,122 @@ def merge_replacement_files(tmpdir: str, mergefile: str) -> None:
         open(mergefile, "w").close()
 
 
+def aggregate_profiles(profile_dir: str) -> Dict[str, float]:
+    """Aggregate timing data from multiple profile JSON files"""
+    aggregated: Dict[str, float] = {}
+
+    for profile_file in glob.iglob(os.path.join(profile_dir, "*.json")):
+        try:
+            with open(profile_file, "r", encoding="utf-8") as f:
+                data = json.load(f)
+                profile_data: Dict[str, float] = data.get("profile", {})
+
+                for key, value in profile_data.items():
+                    if key.startswith("time.clang-tidy."):
+                        if key in aggregated:
+                            aggregated[key] += value
+                        else:
+                            aggregated[key] = value
+        except (json.JSONDecodeError, KeyError, IOError):
+            # Skip malformed or unreadable files
----------------
vbvictor wrote:

No I didn't, placed a warning here.

https://github.com/llvm/llvm-project/pull/151011


More information about the cfe-commits mailing list