[libcxx] [llvm] [libc++] Add tools for gathering historical benchmark data (PR #212775)
Nikolas Klauser via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 5 08:41:40 PDT 2026
================
@@ -0,0 +1,483 @@
+#!/usr/bin/env python3
+# ===----------------------------------------------------------------------===##
+#
+# 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 Dict, List, NamedTuple, Optional, Sequence, TextIO
+import argparse
+import json
+import logging
+import pathlib
+import re
+import subprocess
+import sys
+import tabulate
+import urllib.parse
+
+
+class WorkItem(NamedTuple):
+ """
+ One line of the plan as produced by `plan-benchmarks`.
+ """
+ commit: str
+ machine: str
+ samples_have: int
+ samples_want: int
+ reason: str = ''
+
+ @staticmethod
+ def parse(line: str) -> 'WorkItem':
+ """
+ Read one line of a plan, validating every field.
+
+ A plan is normally produced by `plan-benchmarks`, but it can also be
+ hand-written, so we are careful about validating the data here.
+ """
+ item = json.loads(line)
+ if not isinstance(item, dict):
+ raise ValueError(f'expected a JSON object, got {type(item).__name__}')
+
+ def field(name: str, types, required: bool = True, default=None):
+ if name not in item:
+ if required:
+ raise ValueError(f'missing required field {name}')
+ return default
+ value = item[name]
+ if isinstance(value, bool) or not isinstance(value, types):
----------------
philnik777 wrote:
Why do we check against `bool` specifically?
https://github.com/llvm/llvm-project/pull/212775
More information about the llvm-commits
mailing list