Skip to content

Commit

Permalink
Add codspeed benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
padix-key committed Aug 22, 2024
1 parent bbaa785 commit 87b32ba
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 4 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Install wheel
run: pip install .//dist//*.whl
- name: Test wheel
run: pytest --assert=plain
run: pytest --assert=plain tests
- uses: actions/upload-artifact@v3
with:
path: .//dist//*.whl
Expand All @@ -62,17 +62,30 @@ jobs:
- name: Install source distribution
run: pip install .//dist//*.tar.gz
- name: Test source distribution
run: pytest --assert=plain
run: pytest --assert=plain tests
- uses: actions/upload-artifact@v3
with:
path: dist//*.tar.gz

benchmarks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Install dependencies
run: pip install .[test]
- name: Run benchmarks
uses: CodSpeedHQ/action@v3
with:
run: pytest --codspeed benchmarks

upload:
name: Upload to GitHub Releases & PyPI
permissions:
contents: write
needs: [wheels, sdist]
needs: [wheels, sdist, benchmarks]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
Expand Down
Empty file added benchmarks/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions benchmarks/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from pathlib import Path
import pytest
import fastpdb


@pytest.fixture
def pdb_file_path():
return Path(__file__).parents[1] / "tests" / "data" / "1aki.pdb"


@pytest.fixture
def pdb_file(pdb_file_path):
return fastpdb.PDBFile.read(pdb_file_path)
27 changes: 27 additions & 0 deletions benchmarks/test_get.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pytest
import fastpdb


@pytest.mark.benchmark
def test_read(pdb_file_path):
fastpdb.PDBFile.read(pdb_file_path)


@pytest.mark.benchmark
def test_get_coord(pdb_file):
pdb_file.get_coord(model=1)


@pytest.mark.benchmark
def test_get_structure(pdb_file):
pdb_file.get_structure(model=1)


@pytest.mark.benchmark
def test_get_structure_with_bonds(pdb_file):
pdb_file.get_structure(model=1, include_bonds=True)


@pytest.mark.benchmark
def test_get_remark(pdb_file):
pdb_file.get_remark(350)
23 changes: 23 additions & 0 deletions benchmarks/test_set.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest
import fastpdb


@pytest.fixture
def atoms(pdb_file):
return pdb_file.get_structure(model=1, include_bonds=True)


@pytest.fixture
def empty_pdb_file():
return fastpdb.PDBFile()


@pytest.mark.benchmark
def test_set_structure(atoms, empty_pdb_file):
atoms.bonds = None
empty_pdb_file.set_structure(atoms)


@pytest.mark.benchmark
def test_set_structure_with_bonds(atoms, empty_pdb_file):
empty_pdb_file.set_structure(atoms)
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ classifiers = [
"Topic :: Scientific/Engineering :: Bio-Informatics",
]
dependencies = [
"biotite >= 0.39"
"biotite >= 0.39",
]

[project.optional-dependencies]
# development dependency groups
test = [
"pytest",
"pytest-codspeed",
]

[project.urls]
Expand Down

0 comments on commit 87b32ba

Please sign in to comment.