Skip to content

Commit

Permalink
first benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestoarbitrio committed Sep 28, 2020
1 parent b6f9fe8 commit 08c2f59
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Project
**/__pycache__
coverage_html_report
.benchmarks/

# IDE + OS
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ before_script:
# command to run tests
script:
- flake8 .
- pytest --cov=histolab
- pytest --ignore=tests/benchmarks --cov=histolab

after_success:
- coveralls
Expand Down
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ def ascii_bytes_from(path, *paths):
"typing_extensions",
]

test_requires = ["pytest", "pytest-xdist", "coverage", "pytest-cov", "coveralls"]
test_requires = [
"pytest",
"pytest-xdist",
"coverage",
"pytest-cov",
"coveralls",
"pytest-benchmark",
]

setuptools.setup(
name="histolab",
Expand Down
Empty file added tests/benchmarks/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions tests/benchmarks/test_benchmarks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import numpy as np
from histolab.filters.util import mask_percent, mask_difference


class TestDescribeBenchmarksFilterUnit:
def test_mask_percent(self, benchmark):
mask_array = np.random.choice(a=[False, True], size=(10000, 4000))
benchmark.pedantic(mask_percent, args=[mask_array], iterations=100, rounds=50)

def test_mask_difference(self, benchmark):
minuend = np.random.choice(a=[False, True], size=(5000, 4000))
subtrahend = np.random.choice(a=[False, True], size=(5000, 4000))
benchmark.pedantic(mask_difference, args=[minuend, subtrahend], rounds=100)

0 comments on commit 08c2f59

Please sign in to comment.