Skip to content

Commit

Permalink
finalize runner
Browse files Browse the repository at this point in the history
  • Loading branch information
bbengfort committed Dec 21, 2024
1 parent 3e52795 commit 556dac5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 6 additions & 1 deletion construe/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import torch
import platform

from datetime import datetime

from .version import get_version
from .exceptions import DeviceError

Expand Down Expand Up @@ -77,7 +79,7 @@
@click.option(
"-o",
"--out",
default="construe.json",
default=None,
type=str,
help="specify the path to write the benchmark results to",
)
Expand Down Expand Up @@ -155,6 +157,9 @@ def main(
if env is None:
env = platform.node()

if out is None:
out = f"construe-results-{datetime.now().strftime("%Y%m%d%H%M%S")}.json"

ctx.ensure_object(dict)
ctx.obj["out"] = out
ctx.obj["device"] = device
Expand Down
7 changes: 2 additions & 5 deletions construe/benchmark/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def run(self):
env=self.env,
device=self.device,
options=self.benchmark_kwargs,
errors=[],
)

self.run_complete_ = False
Expand Down Expand Up @@ -148,12 +149,8 @@ def save(self, path):
if not self.is_complete:
raise BenchmarkError("cannot save benchmarks that haven't been run")

output = {}
output.update(self.info_)
output["measurements"] = self.measurements_

with open(path, "w") as o:
dump(o, output)
dump(self.results_, o)


@dataclasses.dataclass(init=True, repr=False, eq=True)
Expand Down

0 comments on commit 556dac5

Please sign in to comment.