k4bench.analysis.loader¶
k4bench.analysis.loader ¶
Load benchmark results and per-event timing data for analysis.
with_cpu_efficiency ¶
Return df with total-CPU/wall cpu_efficiency when measurable.
CPU time means user plus system time everywhere. If any component is absent, the efficiency is unknown and no derived column is attached.
Source code in k4bench/analysis/loader.py
failed_config_mask ¶
Return a boolean mask for configs that did not exit cleanly.
A non-zero, missing, or non-numeric returncode is a failure. Frames
from older result schemas that have no returncode column remain usable:
their success state is unknown, not known-bad, so the returned mask is all
False. Source-column provenance preserves that distinction when old and
new result frames are later concatenated. The mask always preserves df's
index.
Source code in k4bench/analysis/loader.py
config_keys ¶
Return every (run_id, label) pair represented by df.
Source code in k4bench/analysis/loader.py
failed_config_keys ¶
Return failed (run_id, label) pairs from a result-history frame.
Source code in k4bench/analysis/loader.py
judgeable_config_keys ¶
Result config-nights with a recorded success or legacy-unknown status.
config_rows_for_keys ¶
Keep rows whose normalized (run_id, label) pair is in keys.
The helper is the shared join primitive for result-backed derived data. Keeping it separate from the policy helpers below lets callers retain recorded failed rows for diagnostic plots while still rejecting orphaned event/region files.
Source code in k4bench/analysis/loader.py
recorded_config_rows ¶
Keep metric rows backed by any result row, including failed configs.
Source code in k4bench/analysis/loader.py
judgeable_config_rows ¶
Keep metric rows backed by a non-failed result config-night.
Derived event and region frames do not carry returncode themselves, so
they inherit validity from the result frame through (run_id, label).
This also rejects orphaned partial files whose config never wrote a result
row, while retaining healthy sibling configs from the same run.
Source code in k4bench/analysis/loader.py
judgeable_config_data ¶
judgeable_config_data(data: Mapping[str, _T] | None, results_df: DataFrame | None) -> dict[str, _T] | None
Filter a current-run label -> payload mapping to successful configs.
Current event and region files are dict-backed rather than tabular. A label is kept only when the current result frame contains at least one non-failed row for it; failed configs and orphaned partial files therefore follow the same policy as their historical DataFrame counterparts.
Source code in k4bench/analysis/loader.py
load_results ¶
Load benchmark results from a log directory into a DataFrame.
Each {label}_results.csv file written by k4bench is loaded and
concatenated into a single DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_dir
|
str or Path
|
Directory containing |
required |
labels
|
list[str] or None
|
Load only these run labels. Loads all |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per run. Float columns are cast to |
Source code in k4bench/analysis/loader.py
load_event_timing ¶
Load per-event timing JSON files from a log directory.
Each {label}_events.json file written by the k4BenchTimingAction
plugin is parsed into a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_dir
|
str or Path
|
Directory containing |
required |
labels
|
list[str] or None
|
Load only these run labels. If None, all |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, DataFrame]
|
Maps label → DataFrame with columns
|
Raises:
| Type | Description |
|---|---|
ValueError
|
For a JSON root that is not an object, a malformed or unsupported
|
Source code in k4bench/analysis/loader.py
load_region_timing ¶
Load per-region timing JSON files from a log directory.
Each {label}_regions.json file written by the k4BenchRegionTimingAction
plugin is parsed into structured data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_dir
|
str or Path
|
Directory containing |
required |
labels
|
list[str] or None
|
Load only these run labels. If |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
Maps label → dict with keys:
|
Source code in k4bench/analysis/loader.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | |
load_component_timing ¶
load_component_timing(log_dir: str | Path, labels: list[str] | None = None) -> dict[str, ComponentTiming]
Load the per-component files the k4BenchAuditor writes for k4run jobs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_dir
|
str or Path
|
Directory containing |
required |
labels
|
list[str] or None
|
Load only these run labels. If |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, ComponentTiming]
|
Maps label → its :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
For a requested label without a file, an unsupported
|
Source code in k4bench/analysis/loader.py
unreadable_reason ¶
Why path could not be read, from exc: the file's name, the error's class and its message, with the file's full path left out and the message cut short, so it shows none of the file's contents at length.
Source code in k4bench/analysis/loader.py
load_each_component_timing ¶
load_each_component_timing(log_dir: str | Path) -> tuple[dict[str, ComponentTiming], dict[str, str]]
Every label's _components.json in log_dir that could be read
(:func:load_component_timing), and why each other could not. Both empty
when log_dir holds no component files (a ddsim run).
Source code in k4bench/analysis/loader.py
load_each_component_heap ¶
load_each_component_heap(log_dir: str | Path) -> tuple[dict[str, ComponentHeap], dict[str, str]]
Every label's _heap.json in log_dir that could be read
(:func:load_component_heap), and why each other could not. Both empty
when log_dir holds no heap files (no memory pass ran).
Source code in k4bench/analysis/loader.py
load_component_heap ¶
load_component_heap(log_dir: str | Path, labels: list[str] | None = None) -> dict[str, ComponentHeap]
Load the heap files the k4run benchmark's memory pass writes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_dir
|
str or Path
|
Directory containing |
required |
labels
|
list[str] or None
|
Load only these run labels. If |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, ComponentHeap]
|
Maps label → its :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
For a requested label without a file, an unsupported
|
Source code in k4bench/analysis/loader.py
run_suite ¶
The suite of the run in run_dir.
A nightly run records it in its run_info.json. A run made with the
k4bench CLI, or a nightly run older than that field, records none: it
is a reco run exactly when the k4run auditor left a _components.json.