Skip to content
Projects

scope_profiler.benchmark

Repeatable benchmark workflows for coding agents and CI.

The benchmark format is TOML so it works with Python 3.10+ without adding a configuration dependency. A benchmark run produces a JSON manifest containing the individual profile paths, robust summary statistics, and correctness status.

Classes

NameDescription
BenchmarkConfigNo description.
BenchmarkErrorA user-facing benchmark configuration or execution error.

Functions

NameDescription
compare_benchmarksCompare benchmark manifests using medians and report an agent decision.
load_configLoad and validate a benchmark TOML file.
run_benchmarkRun warmups, correctness, and repeated measured profiles.

BenchmarkConfigclassdataclass#

class BenchmarkConfig(name: str, script: str, args: tuple[str, ...] = (), runs: int = 5, warmups: int = 1, timeout_seconds: float = 300.0, only_user_code: bool = True, output_dir: str = '.scope-profiler', correctness_command: tuple[str, ...] = (), correctness_timeout_seconds: float = 300.0, threshold_pct: float = 2.0)

argsattributeclass attributeinstance attribute#

args: tuple[str, ...] = ()

correctness_commandattributeclass attributeinstance attribute#

correctness_command: tuple[str, ...] = ()

correctness_timeout_secondsattributeclass attributeinstance attribute#

correctness_timeout_seconds: float = 300.0

nameattributeinstance attribute#

name: str

only_user_codeattributeclass attributeinstance attribute#

only_user_code: bool = True

output_dirattributeclass attributeinstance attribute#

output_dir: str = '.scope-profiler'

runsattributeclass attributeinstance attribute#

runs: int = 5

scriptattributeinstance attribute#

script: str

threshold_pctattributeclass attributeinstance attribute#

threshold_pct: float = 2.0

timeout_secondsattributeclass attributeinstance attribute#

timeout_seconds: float = 300.0

warmupsattributeclass attributeinstance attribute#

warmups: int = 1

BenchmarkErrorclass#

class BenchmarkError(Exception)

Bases: Exception

A user-facing benchmark configuration or execution error.

compare_benchmarksfunction#

def compare_benchmarks(baseline: dict | str, candidate: dict | str) -> dict

Compare benchmark manifests using medians and report an agent decision.

load_configfunction#

def load_config(path: str | os.PathLike[str]) -> BenchmarkConfig

Load and validate a benchmark TOML file.

run_benchmarkfunction#

def run_benchmark(config: BenchmarkConfig, label: str = 'candidate') -> dict

Run warmups, correctness, and repeated measured profiles.