From 89fe364531f43c90c7bc5e11eff5260782bd3819 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Fri, 10 May 2024 21:09:50 -0400 Subject: [PATCH] benchmark performance of import Do a benchmark before working on #522 Signed-off-by: Jinzhe Zeng --- .github/workflows/test.yml | 5 +++++ pyproject.toml | 4 ++++ tests/benchmark/__init__.py | 0 tests/benchmark/test_import.py | 13 +++++++++++++ 4 files changed, 22 insertions(+) create mode 100644 tests/benchmark/__init__.py create mode 100644 tests/benchmark/test_import.py 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")