calibrax.core.result¤
The BenchmarkResult container — a single benchmark execution result combining
timing, resource, and metric data. Supports JSON serialization and file I/O.
Unified benchmark result container.
Composes TimingSample, ResourceSummary, and Metric into a single serializable BenchmarkResult with JSON save/load support.
BenchmarkResult(*, name, domain='', tags=dict(), timing=None, resources=None, metrics=dict(), metadata=dict(), config=dict(), timestamp=time.time())
dataclass
¤
Framework-agnostic benchmark result.
Composes timing, resource, and metric measurements into a single serializable container for cross-framework comparison.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Benchmark name identifier. |
domain |
str
|
Domain category (e.g., "computer_vision", "nlp"). |
tags |
dict[str, str]
|
Flexible key-value tags (framework, model, variant, etc.). |
timing |
TimingSample | None
|
Timing measurements from TimingCollector. |
resources |
ResourceSummary | None
|
Resource usage from ResourceMonitor. |
metrics |
dict[str, Metric]
|
Named metric values with optional confidence intervals. |
metadata |
dict[str, Any]
|
Additional metadata (system info, hyperparameters, etc.). |
config |
dict[str, Any]
|
Benchmark configuration parameters. |
timestamp |
float
|
Unix timestamp of the benchmark run. |
to_dict()
¤
Serialize to a JSON-compatible dictionary.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary representation with nested objects serialized. |
from_dict(data)
classmethod
¤
Deserialize from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary with benchmark result fields. |
required |
Returns:
| Type | Description |
|---|---|
BenchmarkResult
|
Reconstructed BenchmarkResult instance. |
save(filepath)
¤
Save result to a JSON file, creating parent directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
Path
|
Path to the output JSON file. |
required |
load(filepath)
classmethod
¤
Load a BenchmarkResult from a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
Path
|
Path to the JSON file. |
required |
Returns:
| Type | Description |
|---|---|
BenchmarkResult
|
Reconstructed BenchmarkResult instance. |