diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a17fcde..64462e9b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,11 @@ jobs: uses: codecov/codecov-action@v4 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Run benchmarks + uses: CodSpeedHQ/action@v2 + with: + token: ${{ secrets.CODSPEED_TOKEN }} + run: pytest tests/benchmark/ --codspeed pass: needs: [build] runs-on: ubuntu-latest diff --git a/pyproject.toml b/pyproject.toml index 3f09801a..664dda98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,10 @@ docs = [ 'jupyterlite-sphinx', 'jupyterlite-xeus-python', ] +test = [ + 'pytest', + 'pytest-codspeed', +] [tool.setuptools.packages.find] include = ["dpdata*"] diff --git a/tests/benchmark/__init__.py b/tests/benchmark/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/benchmark/test_import.py b/tests/benchmark/test_import.py new file mode 100644 index 00000000..02232071 --- /dev/null +++ b/tests/benchmark/test_import.py @@ -0,0 +1,13 @@ +import pytest +import subprocess +import sys + +@pytest.mark.benchmark +def test_import(): + """Test import dpdata.""" + subprocess.check_output([sys.executable, "-c", "'from dpdata import LabeledSystem'"]).decode("ascii") + +@pytest.mark.benchmark +def test_cli(): + """Test dpdata command.""" + subprocess.check_output([sys.executable, "-m", "dpdata", "-h"]).decode("ascii")