Skip to content

Commit

Permalink
Merge pull request scikit-image#3234 from lagru/watershed-benchmark
Browse files Browse the repository at this point in the history
Add benchmarks for morphology.watershed
  • Loading branch information
soupault authored Aug 10, 2018
2 parents d1f048e + 5eeae5c commit 7362d6b
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions benchmarks/benchmark_morphology.py
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)

0 comments on commit 7362d6b

Please sign in to comment.