Skip to content

Commit

Permalink
Merge pull request #133 from Purg/dev/benchmark-output-formatting
Browse files Browse the repository at this point in the history
Small formatting update to benchmark util to make easier to read
  • Loading branch information
brianhhu authored Jan 30, 2024
2 parents 07a7806 + 07667c7 commit d479d6d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
7 changes: 6 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
version: 2
formats:
- pdf
build:
os: ubuntu-22.04
tools:
python: "3.8"

python:
version: 3.8
install:
- requirements: docs/readthedocs-reqs.txt
- method: pip
path: .

sphinx:
builder: html
configuration: docs/conf.py
3 changes: 2 additions & 1 deletion docs/readthedocs-reqs.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Additional requirements for building our documentation in read-the-docs build
sphinx-prompt
sphinx-prompt==1.3.0
sphinx-rtd-theme==1.2.2
4 changes: 4 additions & 0 deletions docs/release_notes/pending_release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ Pending Release Notes
Updates / New Features
----------------------

Utils

* Updated logging format of occlusion masking benchmark utility.

Fixes
-----
21 changes: 12 additions & 9 deletions xaitk_saliency/utils/masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,50 +233,53 @@ def benchmark_occlude_image(
perf_counter = time.perf_counter
print(f"Image shape={img_mat.shape}, masks={masks.shape}, fill_1c={fill_1c}, fill_{img_channels}c={fill_mc}")

def log_line(op: str, mode: str, cores: int, fill: str, seconds: float) -> None:
print(f"{op:12s}{mode:16s}{cores:2d} {fill:9s}{seconds} s")

s = perf_counter()
occlude_image_batch(img_mat, masks)
e = perf_counter()
print(f"Batch - no-fill - {e-s} s")
log_line("Batch", "main", 0, "no-fill", e-s)
for threads in threading_tests:
s = perf_counter()
occlude_image_batch(img_mat, masks, threads=threads)
e = perf_counter()
print(f"Batch - threads={threads:2d} - no-fill - {e-s} s")
log_line("Batch", "threads", threads, "no-fill", e - s)
for threads in threading_tests:
s = perf_counter()
np.asarray(list(occlude_image_streaming(img_mat, masks, threads=threads)))
e = perf_counter()
print(f"Streaming - threads={threads:2d} - no-fill - {e-s} s")
log_line("Streaming", "threads", threads, "no-fill", e - s)

s = perf_counter()
occlude_image_batch(img_mat, masks, fill=fill_1c)
e = perf_counter()
print(f"Batch - fill-1c - {e-s} s")
log_line("Batch", "main", 0, "fill-1c", e-s)
for threads in threading_tests:
s = perf_counter()
occlude_image_batch(img_mat, masks, fill=fill_1c, threads=threads)
e = perf_counter()
print(f"Batch - threads={threads:2d} - fill-1c - {e-s} s")
log_line("Batch", "threads", threads, "fill-1c", e - s)
for threads in threading_tests:
s = perf_counter()
np.asarray(list(occlude_image_streaming(img_mat, masks, fill=fill_1c, threads=threads)))
e = perf_counter()
print(f"Streaming - threads={threads:2d} - fill-1c - {e-s} s")
log_line("Streaming", "threads", threads, "fill-1c", e - s)

s = perf_counter()
occlude_image_batch(img_mat, masks, fill=fill_mc)
e = perf_counter()
print(f"Batch - fill-{img_channels}c - {e-s} s")
log_line("Batch", "main", 0, f"fill-{img_channels}c", e-s)
for threads in threading_tests:
s = perf_counter()
occlude_image_batch(img_mat, masks, fill=fill_mc, threads=threads)
e = perf_counter()
print(f"Batch - threads={threads:2d} - fill-{img_channels}c - {e-s} s")
log_line("Batch", "threads", threads, f"fill-{img_channels}c", e - s)
for threads in threading_tests:
s = perf_counter()
np.asarray(list(occlude_image_streaming(img_mat, masks, fill=fill_mc, threads=threads)))
e = perf_counter()
print(f"Streaming - threads={threads:2d} - fill-{img_channels}c - {e-s} s")
log_line("Streaming", "threads", threads, f"fill-{img_channels}c", e - s)


def weight_regions_by_scalar(
Expand Down

0 comments on commit d479d6d

Please sign in to comment.