Skip to content

Commit 9b258d8

Browse files
committed
test: add benches for TheAlgorithms/audio_filters
1 parent 0ece3ff commit 9b258d8

File tree

9 files changed

+59
-2
lines changed

9 files changed

+59
-2
lines changed

.github/workflows/codspeed.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ jobs:
1010
benchmarks:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
14+
with:
15+
submodules: "recursive"
1416
- name: Set up Python 3.12
1517
uses: actions/setup-python@v2
1618
with:

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "tests/benchmarks/TheAlgorithms"]
2+
path = tests/benchmarks/TheAlgorithms
3+
url = [email protected]:TheAlgorithms/Python.git

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ force_grid_wrap = 0
8787
float_to_top = true
8888

8989
[tool.pytest.ini_options]
90-
addopts = "--ignore=tests/benchmarks --ignore=tests/examples"
90+
addopts = "--ignore=tests/benchmarks --ignore=tests/examples --ignore=tests/benchmarks/TheAlgorithms"
9191
filterwarnings = ["ignore::DeprecationWarning:pytest_benchmark.utils.*:"]
92+
pythonpath = ["tests/benchmarks/TheAlgorithms"]
9293

9394
[tool.coverage.run]
9495
branch = true

tests/benchmarks/TheAlgorithms

Submodule TheAlgorithms added at 77bbe58

tests/benchmarks/TheAlgorithms_bench/__init__.py

Whitespace-only changes.

tests/benchmarks/TheAlgorithms_bench/audio_filters/__init__.py

Whitespace-only changes.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from audio_filters.butterworth_filter import (
2+
make_allpass,
3+
make_bandpass,
4+
make_highpass,
5+
make_highshelf,
6+
make_lowpass,
7+
make_lowshelf,
8+
make_peak,
9+
)
10+
11+
12+
def test_make_lowpass(benchmark):
13+
benchmark(make_lowpass, 1000, 48000)
14+
15+
16+
def test_make_highpass(benchmark):
17+
benchmark(make_highpass, 1000, 48000)
18+
19+
20+
def test_make_bandpass(benchmark):
21+
benchmark(make_bandpass, 1000, 48000)
22+
23+
24+
def test_make_allpass(benchmark):
25+
benchmark(make_allpass, 1000, 48000)
26+
27+
28+
def test_make_peak(benchmark):
29+
benchmark(make_peak, 1000, 48000, 6)
30+
31+
32+
def test_make_lowshelf(benchmark):
33+
benchmark(make_lowshelf, 1000, 48000, 6)
34+
35+
36+
def test_make_highshelf(benchmark):
37+
benchmark(make_highshelf, 1000, 48000, 6)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from audio_filters.iir_filter import IIRFilter
2+
3+
4+
def test_set_coefficients(benchmark):
5+
filt = IIRFilter(2)
6+
a_coeffs = [1.0, -1.8, 0.81]
7+
b_coeffs = [0.9, -1.8, 0.81]
8+
benchmark(filt.set_coefficients, a_coeffs, b_coeffs)
9+
10+
11+
def test_process(benchmark):
12+
filt = IIRFilter(2)
13+
benchmark(filt.process, 0)

tests/benchmarks/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)