forked from scikit-image/scikit-image
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scikit-image#3234 from lagru/watershed-benchmark
Add benchmarks for morphology.watershed
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 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,38 @@ | ||
"""Benchmarks for `skimage.morphology`.""" | ||
|
||
|
||
import numpy as np | ||
from skimage import data, filters, morphology | ||
|
||
|
||
class Watershed(object): | ||
|
||
param_names = ["seed_count", "connectivity", "compactness"] | ||
params = [(5, 500), (1, 2), (0, 0.01)] | ||
|
||
def setup(self, *args): | ||
self.image = filters.sobel(data.coins()) | ||
|
||
def time_watershed(self, seed_count, connectivity, compactness): | ||
morphology.watershed(self.image, seed_count, connectivity, | ||
compactness=compactness) | ||
|
||
def peakmem_reference(self, *args): | ||
"""Provide reference for memory measurement with empty benchmark. | ||
Peakmem benchmarks measure the maximum amount of RAM used by a | ||
function. However, this maximum also includes the memory used | ||
during the setup routine (as of asv 0.2.1; see [1]_). | ||
Measuring an empty peakmem function might allow us to disambiguate | ||
between the memory used by setup and the memory used by target (see | ||
other ``peakmem_`` functions below). | ||
References | ||
---------- | ||
.. [1]: http://asv.readthedocs.io/en/stable/writing_benchmarks.html#peak-memory | ||
""" | ||
pass | ||
|
||
def peakmem_watershed(self, seed_count, connectivity, compactness): | ||
morphology.watershed(self.image, seed_count, connectivity, | ||
compactness=compactness) |