Skip to content

Commit 13ad20c

Browse files
committed
Expose benchmark params dataclass stub
This is intended as a base class holding benchmark parameters. Users should subclass this to their needs. Also allows a stronger-typed interface for `params` arguments, e.g. in `BenchmarkRunner.run()`.
1 parent 01906eb commit 13ad20c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/mlbench/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
pass
1010

1111
# TODO: This naming is unfortunate
12-
from .core import Benchmark, benchmark, parametrize
12+
from .core import Benchmark, Params, benchmark, parametrize

src/mlbench/core.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ def NoOp(**kwargs: Any) -> None:
1010
pass
1111

1212

13+
# TODO: Should this be frozen (since the setUp and tearDown hooks are empty returns)?
14+
@dataclass(init=False)
15+
class Params:
16+
"""
17+
A dataclass designed to hold benchmark parameters. This class is not functional
18+
on its own, and needs to be subclassed according to your benchmarking workloads.
19+
20+
The main advantage over passing parameters as a dictionary is, of course,
21+
static analysis and type safety for your benchmarking code.
22+
"""
23+
24+
pass
25+
26+
1327
@dataclass(frozen=True)
1428
class Benchmark:
1529
"""

0 commit comments

Comments
 (0)