Skip to content

Commit

Permalink
benchmark performance of import (#653)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
njzjz and pre-commit-ci[bot] authored May 15, 2024
1 parent 7bb74f4 commit 02309f7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Python package

on:
- push
- pull_request

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dependencies
run: uv pip install --system .[amber,ase,pymatgen,benchmark] rdkit openbabel-wheel
- name: Run benchmarks
uses: CodSpeedHQ/action@v2
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: pytest benchmark/ --codspeed
Empty file added benchmark/__init__.py
Empty file.
18 changes: 18 additions & 0 deletions benchmark/test_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import subprocess
import sys

import pytest


@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")
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ docs = [
'jupyterlite-sphinx',
'jupyterlite-xeus',
]
benchmark = [
'pytest',
'pytest-codspeed',
]

[tool.setuptools.packages.find]
include = ["dpdata*"]
Expand Down

0 comments on commit 02309f7

Please sign in to comment.