8000 ci(tests): add speed benchmark using CodSpeed by frgfm · Pull Request #270 · frgfm/torch-cam · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ci(tests): add speed benchmark using CodSpeed #270

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
25 changes: 25 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: main
pull_request:
branches: main
workflow_dispatch:

jobs:
pytest:
Expand Down Expand Up @@ -32,6 +33,30 @@ jobs:
name: coverage-reports
path: ./coverage.xml

benchmarks:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python: [3.9]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Install dependencies
run: |
python -m pip install --upgrade uv
uv pip install --system -e ".[test]"
- name: Run benchmarks
uses: CodSpeedHQ/action@v3
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: pytest --codspeed tests/

codecov-upload:
runs-on: ubuntu-latest
needs: pytest
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ test = [
"pytest>=7.3.2",
"pytest-cov>=3.0.0,<5.0.0",
"pytest-pretty>=1.0.0,<2.0.0",
"pytest-codspeed>=2.2.1,<3.0.0",
]
quality = [
"ruff==0.5.7",
Expand Down Expand Up @@ -76,6 +77,7 @@ dev = [
"pytest>=7.3.2",
"pytest-cov>=4.0.0,<5.0.0",
"pytest-pretty>=1.0.0,<2.0.0",
"pytest-codspeed>=2.2.1,<3.0.0",
# style
"ruff==0.5.7",
"mypy==1.10.0",
Expand Down
2 changes: 2 additions & 0 deletions tests/test_metrics.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from functools import partial

import pytest
import torch
from torchvision.models import mobilenet_v3_small

from torchcam import metrics
from torchcam.methods import LayerCAM


@pytest.mark.benchmark
def test_classification_metric():
model = mobilenet_v3_small(weights=None)
with LayerCAM(model, "features.12") as extractor:
Expand Down
Loading
0