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
|
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
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 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 | |