Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stash benchmark work #19

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,6 @@ src/stack_to_chunk/_version.py

docs/auto_examples
docs/sg_execution_times.rst

memray*.bin
benchmarks/data
39 changes: 39 additions & 0 deletions benchmarks/behnchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Benchmark
"""

import pathlib
import shutil
import time

import dask_image.imread
import numpy as np
import tifffile

import stack_to_chunk

if __name__ == "__main__":
plane = np.random.randint(low=0, high=2**16, size=(2000, 2000), dtype=np.uint16)
image_dir = pathlib.Path(__file__).parent / "data"
if not image_dir.exists():
image_dir.mkdir()
for i in range(64):
tifffile.imwrite(image_dir / f"{str(i).zfill(3)}.tif", plane)

images = dask_image.imread.imread(str(image_dir / "*.tif")).T
print(f"Volume size: {images.nbytes / 1e6} MB")

for n_processes in [1, 2, 3, 4]:
shutil.rmtree(image_dir / "chunked.zarr")
group = stack_to_chunk.MultiScaleGroup(
image_dir / "chunked.zarr",
name="my_zarr_group",
spatial_unit="centimeter",
voxel_size=(3, 4, 5),
)
t_start = time.time()
group.add_full_res_data(
images, chunk_size=32, compressor="default", n_processes=n_processes
)
t_end = time.time()
print(f"{n_processes=}, t={t_end - t_start} seconds")
Loading