Skip to content

Commit

Permalink
Expose benchmark params dataclass stub
Browse files Browse the repository at this point in the history
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()`.
  • Loading branch information
nicholasjng committed Jan 15, 2024
1 parent 01906eb commit 13ad20c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/mlbench/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
pass

# TODO: This naming is unfortunate
from .core import Benchmark, benchmark, parametrize
from .core import Benchmark, Params, benchmark, parametrize
14 changes: 14 additions & 0 deletions src/mlbench/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ def NoOp(**kwargs: Any) -> None:
pass


# TODO: Should this be frozen (since the setUp and tearDown hooks are empty returns)?
@dataclass(init=False)
class Params:
"""
A dataclass designed to hold benchmark parameters. This class is not functional
on its own, and needs to be subclassed according to your benchmarking workloads.
The main advantage over passing parameters as a dictionary is, of course,
static analysis and type safety for your benchmarking code.
"""

pass


@dataclass(frozen=True)
class Benchmark:
"""
Expand Down

0 comments on commit 13ad20c

Please sign in to comment.