mcframework.benchmark.benchmark_run#

mcframework.benchmark.benchmark_run(sim: MonteCarloSimulation, n: int, spec: BackendSpec, *, n_workers: int | None = None, repeats: int = 1, seed: int = 42, warmup: bool = False) BenchmarkResult | None[source]#

Time one (backend, size) cell.

Runs the workload repeats times and keeps the best (minimum) wall-clock time, which is the standard way to suppress scheduler/GC noise.

Parameters:
simMonteCarloSimulation

Simulation to benchmark.

nint

Number of draws.

specBackendSpec

Backend/device to use.

n_workersint, optional

Worker count for parallel backends.

repeatsint, default 1

Number of timed repetitions; the minimum time is reported.

seedint, default 42

Seed applied before each repetition for reproducibility.

warmupbool, default False

If True, run once and return None (used to prime pools/JIT/caches).

Returns:
BenchmarkResult or None

None for warmup runs or if the backend raised (e.g. Torch missing).

Notes

ponytail: best-of-N is the simple denoiser here; it does not capture variance or per-operator cost. Upgrade path for kernel-level detail is mcframework.profiling.