Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add benches for TheAlgorithms/audio_filters #42

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = git@github.com: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.
Loading