Skip to content

Commit

Permalink
Export experiment duration in seconds in CSV. (#2392)
Browse files Browse the repository at this point in the history
* Export experiment duration in seconds in CSV.

Signed-off-by: Weilin Xu <[email protected]>

* Update CHANGELOG

Signed-off-by: Weilin Xu <[email protected]>

* Log fit and test durations separately.

Signed-off-by: Weilin Xu <[email protected]>

---------

Signed-off-by: Weilin Xu <[email protected]>
Co-authored-by: Samet Akcay <[email protected]>
  • Loading branch information
mzweilin and samet-akcay authored Oct 24, 2024
1 parent 0301d59 commit c00e101
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Changed

- Add duration of experiments in seconds in the benchmark CSV result by [mzweilin](https://github.com/mzweilin) in https://github.com/openvinotoolkit/anomalib/pull/2392

### Deprecated

### Fixed
Expand Down
11 changes: 11 additions & 0 deletions src/anomalib/pipelines/benchmark/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# SPDX-License-Identifier: Apache-2.0

import logging
import time
from datetime import datetime
from pathlib import Path
from tempfile import TemporaryDirectory
Expand Down Expand Up @@ -48,6 +49,7 @@ def run(
task_id: int | None = None,
) -> dict[str, Any]:
"""Run the benchmark."""
job_start_time = time.time()
devices: str | list[int] = "auto"
if task_id is not None:
devices = [task_id]
Expand All @@ -59,8 +61,16 @@ def run(
devices=devices,
default_root_dir=temp_dir,
)
fit_start_time = time.time()
engine.fit(self.model, self.datamodule)
test_start_time = time.time()
test_results = engine.test(self.model, self.datamodule)
job_end_time = time.time()
durations = {
"job_duration": job_end_time - job_start_time,
"fit_duration": test_start_time - fit_start_time,
"test_duration": job_end_time - test_start_time,
}
# TODO(ashwinvaidya17): Restore throughput
# https://github.com/openvinotoolkit/anomalib/issues/2054
output = {
Expand All @@ -69,6 +79,7 @@ def run(
"model": self.model.__class__.__name__,
"data": self.datamodule.__class__.__name__,
"category": self.datamodule.category,
**durations,
**test_results[0],
}
logger.info(f"Completed with result {output}")
Expand Down

0 comments on commit c00e101

Please sign in to comment.