Skip to content

Commit 02309f7

Browse files
benchmark performance of import (#653)
Do a benchmark before working on #526 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced benchmark tests for import functionality and command line interface operations. - **Tests** - Added new benchmark tests to assess performance improvements. - **Chores** - Integrated `pytest` and `pytest-codspeed` into the project for enhanced testing capabilities. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Jinzhe Zeng <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 7bb74f4 commit 02309f7

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

.github/workflows/benchmark.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Python package
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Python
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: 3.12
16+
- run: curl -LsSf https://astral.sh/uv/install.sh | sh
17+
- name: Install dependencies
18+
run: uv pip install --system .[amber,ase,pymatgen,benchmark] rdkit openbabel-wheel
19+
- name: Run benchmarks
20+
uses: CodSpeedHQ/action@v2
21+
with:
22+
token: ${{ secrets.CODSPEED_TOKEN }}
23+
run: pytest benchmark/ --codspeed

benchmark/__init__.py

Whitespace-only changes.

benchmark/test_import.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import subprocess
2+
import sys
3+
4+
import pytest
5+
6+
7+
@pytest.mark.benchmark
8+
def test_import():
9+
"""Test import dpdata."""
10+
subprocess.check_output(
11+
[sys.executable, "-c", "'from dpdata import LabeledSystem'"]
12+
).decode("ascii")
13+
14+
15+
@pytest.mark.benchmark
16+
def test_cli():
17+
"""Test dpdata command."""
18+
subprocess.check_output([sys.executable, "-m", "dpdata", "-h"]).decode("ascii")

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ docs = [
5858
'jupyterlite-sphinx',
5959
'jupyterlite-xeus',
6060
]
61+
benchmark = [
62+
'pytest',
63+
'pytest-codspeed',
64+
]
6165

6266
[tool.setuptools.packages.find]
6367
include = ["dpdata*"]

0 commit comments

Comments
 (0)