Skip to content

Commit

Permalink
test: add benches for TheAlgorithms/audio_filters
Browse files Browse the repository at this point in the history
  • Loading branch information
art049 committed Sep 18, 2024
1 parent 0ece3ff commit 9b258d8
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ jobs:
benchmarks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Set up Python 3.12
uses: actions/setup-python@v2
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tests/benchmarks/TheAlgorithms"]
path = tests/benchmarks/TheAlgorithms
url = [email protected]:TheAlgorithms/Python.git
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ force_grid_wrap = 0
float_to_top = true

[tool.pytest.ini_options]
addopts = "--ignore=tests/benchmarks --ignore=tests/examples"
addopts = "--ignore=tests/benchmarks --ignore=tests/examples --ignore=tests/benchmarks/TheAlgorithms"
filterwarnings = ["ignore::DeprecationWarning:pytest_benchmark.utils.*:"]
pythonpath = ["tests/benchmarks/TheAlgorithms"]

[tool.coverage.run]
branch = true
Expand Down
1 change: 1 addition & 0 deletions tests/benchmarks/TheAlgorithms
Submodule TheAlgorithms added at 77bbe5
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from audio_filters.butterworth_filter import (
make_allpass,
make_bandpass,
make_highpass,
make_highshelf,
make_lowpass,
make_lowshelf,
make_peak,
)


def test_make_lowpass(benchmark):
benchmark(make_lowpass, 1000, 48000)


def test_make_highpass(benchmark):
benchmark(make_highpass, 1000, 48000)


def test_make_bandpass(benchmark):
benchmark(make_bandpass, 1000, 48000)


def test_make_allpass(benchmark):
benchmark(make_allpass, 1000, 48000)


def test_make_peak(benchmark):
benchmark(make_peak, 1000, 48000, 6)


def test_make_lowshelf(benchmark):
benchmark(make_lowshelf, 1000, 48000, 6)


def test_make_highshelf(benchmark):
benchmark(make_highshelf, 1000, 48000, 6)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from audio_filters.iir_filter import IIRFilter


def test_set_coefficients(benchmark):
filt = IIRFilter(2)
a_coeffs = [1.0, -1.8, 0.81]
b_coeffs = [0.9, -1.8, 0.81]
benchmark(filt.set_coefficients, a_coeffs, b_coeffs)


def test_process(benchmark):
filt = IIRFilter(2)
benchmark(filt.process, 0)
Empty file added tests/benchmarks/__init__.py
Empty file.

0 comments on commit 9b258d8

Please sign in to comment.