k4bench.benchmark.ddsim¶
k4bench.benchmark.ddsim ¶
Benchmark ddsim across geometry configurations.
This module is the top-level orchestrator. It wires together:
- :mod:
k4bench.geometry.scanner— discover subdetector names - :mod:
k4bench.geometry.patcher— produce patched XML files - :mod:
k4bench.runner.executor— time each ddsim run - :mod:
k4bench.results.model— collect results
All runs are sequential. Parallel execution would skew wall-time and RSS metrics because competing processes share CPU, cache, and memory
Sweep modes
FULL Baseline (full geometry) + one run per subdetector with that detector removed. INCLUDE_ONLY Single run with only the named detectors active (all others removed). No baseline. EXCLUDE_ONLY Single run with the named detectors removed (all others active). No additional baseline. Empty detector_names falls back to a full-geometry run.
SweepMode ¶
Bases: Enum
Selects which benchmark strategy :func:run_sweep executes.
BenchmarkConfig
dataclass
¶
BenchmarkConfig(xml_path: Path, n_events: int, output_file: Path, log_dir: Path, mode: SweepMode = FULL, detector_names: list[str] = list(), setup_script: Path | None = None, extra_args: list[str] = list(), verbose: bool = False)
All parameters needed to run a benchmark sweep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xml_path
|
Path
|
Top-level compact XML for the primary geometry. |
required |
n_events
|
int
|
Number of events to simulate per run. |
required |
output_file
|
Path
|
Temporary EDM4hep ROOT file written by ddsim. Reused across runs (overwritten each time); only its size at run-end matters. |
required |
log_dir
|
Path
|
Directory where per-run |
required |
mode
|
SweepMode
|
Which benchmark strategy to execute; see :class: |
FULL
|
detector_names
|
list[str]
|
For |
list()
|
setup_script
|
Path | None
|
Optional shell script sourced before each ddsim invocation. |
None
|
extra_args
|
list[str]
|
Additional ddsim arguments passed verbatim to every run
(e.g. |
list()
|
verbose
|
bool
|
If True, print ddsim stdout in real time instead of buffering until run-end. |
False
|
run_sweep ¶
run_sweep(config: BenchmarkConfig) -> list[RunResult]
Execute a benchmark sweep and return all results.
Dispatches to the appropriate strategy based on config.mode.
Failed ddsim runs are marked with a non-zero return code and
included in the results; the sweep always continues to completion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BenchmarkConfig
|
All parameters for the sweep; see :class: |
required |
Returns:
| Type | Description |
|---|---|
list[RunResult]
|
Results in execution order. |