-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
admin/4.0-release-prep-and-benchmark-upgrades (#244)
* Ignore presentations dir from language * Try double star for ignore lang * Add benchmark for chunk size variability * Fix default and lif bench, add chunk compare * Benchmark aicsimageio against other libs * Use variance cfe instead of pipeline 4 * Configure better lib compare bench * Remove extra deps from benchmark deps * Cleanup lib compare * Reduce the amount of files checked during benchs * Fix benchmark params on TIFF like * Fix comment in random sample * Fix typo
- Loading branch information
Jackson Maxfield Brown
authored
May 30, 2021
1 parent
738ce92
commit 8c7d4f5
Showing
6 changed files
with
175 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
presentations/** linguist-documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import dask.array as da | ||
import random | ||
from pathlib import Path | ||
|
||
from aicsimageio import AICSImage | ||
|
||
from .benchmark_image_containers import _ImageContainerTimeSuite | ||
|
||
############################################################################### | ||
|
||
# We only benchmark against local files as remote files are covered by unit tests | ||
# and are generally slower than local but scale at a similar rate. | ||
LOCAL_RESOURCES_DIR = ( | ||
Path(__file__).parent.parent / "aicsimageio" / "tests" / "resources" | ||
) | ||
|
||
############################################################################### | ||
|
||
|
||
class ChunkSuite(_ImageContainerTimeSuite): | ||
# This suite measures the effect that changing the default chunk dims | ||
# has on the duration of various reads. | ||
# We would expect that processing speed can be optimized based off of the | ||
# dimensions of the file and what the user is trying to do with said file. | ||
# i.e. If the user wants to normalize each channel and make a max projection | ||
# through Z, then the default of 'ZYX' is preferred over just 'YX'. | ||
# During this suite we not only benchmark the above example but also | ||
# file reading under the various chunk configurations as a monitor | ||
# for general read performance. | ||
|
||
params = ( | ||
[ | ||
str(LOCAL_RESOURCES_DIR / "pre-variance-cfe.ome.tiff"), | ||
str(LOCAL_RESOURCES_DIR / "variance-cfe.ome.tiff"), | ||
], | ||
# We don't go above chunking by three dims because it would be rare | ||
# to do so... if you can read four-plus dims in a single chunk why can't you | ||
# just read in the whole image at once. | ||
# We also use CYX here to show that chunking with the _wrong_ dimensions can | ||
# result in longer processing times. | ||
[ | ||
"YX", | ||
"ZYX", | ||
"CYX", | ||
], | ||
) | ||
|
||
def time_norm_and_project(self, img_path, chunk_dims): | ||
""" | ||
Benchmark how long a norm and project through Z takes | ||
under various chunk dims configurations. | ||
""" | ||
# Init image container | ||
r = self.ImageContainer(img_path, chunk_dims=chunk_dims) | ||
|
||
# Store all delayed projections | ||
projs = [] | ||
|
||
# Only run a random sample of two channels instead of all | ||
selected_channels = random.sample(r.channel_names, 2) | ||
for i, channel_name in enumerate(r.channel_names): | ||
if channel_name in selected_channels: | ||
# Select each channel | ||
data = r.get_image_dask_data("ZYX", C=i) | ||
|
||
# Get percentile norm by values | ||
min_px_val, max_px_val = da.percentile( | ||
data.flatten(), | ||
[50.0, 99.8], | ||
).compute() | ||
|
||
# Norm | ||
normed = (data - min_px_val) / (max_px_val - min_px_val) | ||
|
||
# Clip any values outside of 0 and 1 | ||
clipped = da.clip(normed, 0, 1) | ||
|
||
# Scale them between 0 and 255 | ||
scaled = clipped * 255 | ||
|
||
# Create max project | ||
projs.append(scaled.max(axis=0)) | ||
|
||
# Compute all projections | ||
projs = da.stack(projs) | ||
projs.compute() | ||
|
||
def setup(self, img_path, chunk_dims): | ||
random.seed(42) | ||
self.ImageContainer = AICSImage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters