Skip to content

Commit

Permalink
Add performance tests with PGO on x86_64 Ubuntu (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshalX authored Mar 9, 2024
1 parent 9bef349 commit de9738c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
31 changes: 28 additions & 3 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,40 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12" # use the latest version of Python because it is faster

- name: Install dependencies.
- name: Install python dependencies.
run: pip install ".[dev]"

- name: Install rust stable.
id: rust-toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools

- name: Cache rust.
uses: Swatinem/rust-cache@v2

- name: Compile.
run: pip install -v -e .
env:
RUSTFLAGS: "-Cprofile-generate=${{ github.workspace }}/profdata"

- name: Gather PGO data.
run: pytest . --benchmark-enable

- name: Prepare merged PGO data.
run: rustup run stable bash -c '$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata'

- name: Compile with profile.
run: pip install -v -e .
env:
RUSTFLAGS: "-Cprofile-use=${{ github.workspace }}/merged.profdata"

- name: Run benchmarks.
uses: CodSpeedHQ/action@v2
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: pytest . --codspeed
run: pytest . --codspeed -n auto
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ classifiers = [
"Author" = "https://github.com/MarshalX"

[project.optional-dependencies]
dev = ["pytest", "pytest-benchmark", "pytest-codspeed"]
dev = ["pytest==7.4.4", "pytest-benchmark==4.0.0", "pytest-codspeed==2.2.0", "pytest-xdist==3.5.0"]

[tool.pytest.ini_options]
addopts = [
Expand Down

0 comments on commit de9738c

Please sign in to comment.