Skip to content

Commit 0c64f8c

Browse files
authored
Add Codspeed (#1)
1 parent ace3fa0 commit 0c64f8c

4 files changed

Lines changed: 51 additions & 0 deletions

File tree

File renamed without changes.

.github/workflows/codspeed.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CodSpeed
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
id-token: write
13+
14+
jobs:
15+
codspeed:
16+
name: Run benchmarks
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Setup Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.12"
24+
- name: Install dependencies
25+
run: pip install -r requirements.txt
26+
- name: Build Python package with maturin
27+
uses: PyO3/maturin-action@v1
28+
with:
29+
args: --release --out dist
30+
- name: Install base64_utils
31+
run: pip install base64_utils --no-index --find-links dist --force-reinstall
32+
- name: Run benchmarks
33+
uses: CodSpeedHQ/action@v4.5.2
34+
with:
35+
mode: simulation
36+
run: pytest tests/test_benchmarks.py --codspeed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ mkdocs==1.6.1
22
mkdocs-material==9.5.34
33
mypy==1.19.0
44
pytest==9.0.1
5+
pytest-codspeed==4.2.0
56
ruff==0.14.7
67
richbench==1.0.3

tests/test_benchmarks.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import base64_utils
2+
import pytest
3+
4+
pytest.importorskip("pytest_codspeed")
5+
6+
7+
@pytest.mark.benchmark
8+
def test_b64encode() -> None:
9+
base64_utils.b64encode(b"test data")
10+
11+
12+
@pytest.mark.benchmark
13+
def test_b64encode_altchars() -> None:
14+
base64_utils.b64encode(b"test data", altchars=b"-_")

0 commit comments

Comments
 (0)