Skip to content

Commit 3eb94cc

Browse files
committed
add codspeed
1 parent 34df3bc commit 3eb94cc

File tree

4 files changed

+158
-2
lines changed

4 files changed

+158
-2
lines changed

.github/workflows/Bench.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
branches:
66
- main
77

8+
env:
9+
UV_CACHE_DIR: "/tmp/.uv-cache"
10+
811
jobs:
912
benchmark_with_bencher:
1013
name: Continuous Benchmarking with Bencher
@@ -19,7 +22,15 @@ jobs:
1922
- name: Set up Python
2023
uses: actions/setup-python@v5
2124
with:
22-
python-version: ${{ matrix.python-version }}
25+
python-version: 3.12
26+
- name: Restore uv cache
27+
uses: actions/cache@v4
28+
with:
29+
path: ${{ env.UV_CACHE_DIR }}
30+
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
31+
restore-keys: |
32+
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
33+
uv-${{ runner.os }}
2334
2435
- uses: bencherdev/bencher@main
2536
- name: Install tzfpy and test
@@ -34,3 +45,34 @@ jobs:
3445
--adapter python_pytest \
3546
--err \
3647
"pytest --benchmark-json results.json tests/test_bench.py"
48+
49+
benchmark_with_codspeed:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
- name: Set up uv
54+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
55+
- name: Set up Python
56+
uses: actions/setup-python@v5
57+
with:
58+
python-version: 3.12
59+
- name: Restore uv cache
60+
uses: actions/cache@v4
61+
with:
62+
path: ${{ env.UV_CACHE_DIR }}
63+
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
64+
restore-keys: |
65+
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
66+
uv-${{ runner.os }}
67+
68+
- name: Install
69+
run: uv sync
70+
71+
- name: Run benchmarks
72+
uses: CodSpeedHQ/action@v3
73+
with:
74+
# token: ${{ secrets.CODSPEED_TOKEN }}
75+
run: uv run pytest tests/ --codspeed
76+
77+
- name: Minimize uv cache
78+
run: uv cache prune --ci

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ dev-dependencies = [
4343
"pytest-pretty>=1.2.0",
4444
"pytz>=2024.2",
4545
"tzdata>=2024.1",
46+
"pytest-codspeed>=2.2.1",
4647
]

tests/test_bench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ def _test_tzfpy_random_city():
1313

1414

1515
def test_tzfpy_random_cities(benchmark):
16-
benchmark.pedantic(_test_tzfpy_random_city, rounds=20000, iterations=10)
16+
benchmark(_test_tzfpy_random_city)

0 commit comments

Comments
 (0)