[libcxx-commits] [libcxx] [libc++] Add scripts to run benchmarks and submit to LNT on a regular basis (PR #180849)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 11 03:36:15 PST 2026


================
@@ -0,0 +1,116 @@
+#!/usr/bin/env python
+# ===----------------------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+# ===----------------------------------------------------------------------===##
+
+from typing import List, Set
+import argparse
+import json
+import logging
+import os
+import pathlib
+import subprocess
+import sys
+
+
+def directory_path(string):
+    if os.path.isdir(string):
+        return pathlib.Path(string)
+    else:
+        raise NotADirectoryError(string)
+
+def api(lnt_url: str, test_suite: str, endpoint: str):
+    url = f'{lnt_url}/api/db_default/v4/{test_suite}{endpoint}'
+    logging.debug(f'Querying {url}')
+    result = json.loads(subprocess.check_output(['curl', '-sS', url]).decode())
+    return result
+
+def get_benchmarked_commits(lnt_url: str, test_suite: str, machine: str) -> Set[str]:
+    """
+    Return the set of commits that have already been benchmarked on the given LNT
+    instance, test suite and machine.
+    """
+    result = api(lnt_url, test_suite, f'/machines/{machine}')
+    commits = set()
+    if 'runs' not in result: # there is no such machine
+        return set()
+    for run in result['runs']:
+        if 'git_sha' not in run:
+            raise ValueError(f'Found run without a git_sha field: are you using the right LNT test suite? {run}')
+        commits.add(run['git_sha'])
+    return commits
+
+def git_rev_list(git_repo: str, paths: List[str] = []) -> List[str]:
+    """
+    Return the list of all revisions in the given Git repository. Older commits are earlier in the list.
+    """
+    cli = ['git', '-C', git_repo, 'rev-list', 'origin', '--', *paths]
+    rev_list = subprocess.check_output(cli).decode().strip().splitlines()
+    return list(reversed(rev_list))
+
+def git_sorted_revlist(git_repo: str, commits: List[str]) -> List[str]:
----------------
philnik777 wrote:

```suggestion
def git_sort_revlist(git_repo: str, commits: List[str]) -> List[str]:
```

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


More information about the libcxx-commits mailing list