Skip to content

Commit 855ca5b

Browse files
authored
Add wheel-based asv benchmarks and CI speed test workflow (#159)
* Add wheel-based asv benchmarks and CI speed test workflow * fix version
1 parent cc2671b commit 855ca5b

File tree

6 files changed

+98
-0
lines changed

6 files changed

+98
-0
lines changed

.github/workflows/speedtest.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on:
2+
pull_request:
3+
workflow_dispatch:
4+
name: Speed Test
5+
permissions:
6+
contents: read
7+
jobs:
8+
asv-continuous:
9+
name: asv continuous
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 60
12+
steps:
13+
- uses: actions/checkout@v6
14+
with:
15+
fetch-depth: 0
16+
persist-credentials: false
17+
- uses: actions/setup-python@v6
18+
with:
19+
python-version: "3.14"
20+
architecture: "x64"
21+
- run: python -m pip install -U pip wheel setuptools
22+
- run: python -m pip install -r test-requirements.txt
23+
- run: python -m pip install asv build
24+
- run: asv machine --yes
25+
- run: asv continuous origin/${{ github.base_ref }} HEAD --factor 1.10 --show-stderr

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ target/
6767
.ipynb_checkpoints
6868

6969
bencoder.c
70+
71+
# asv
72+
.asv/

AGENTS.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Local Setup
2+
3+
## Build + test from wheel
4+
5+
```bash
6+
python3 -m venv .venv
7+
source .venv/bin/activate
8+
python -m pip install -U pip wheel setuptools
9+
python -m pip install -r test-requirements.txt
10+
python -m pip install build asv
11+
python -m build --wheel --no-isolation
12+
python -m pip install --force-reinstall dist/*.whl
13+
python -m pytest -q tests
14+
```
15+
16+
## Benchmarks (asv)
17+
18+
Uses `tests/debian-8.3.0-amd64-netinst.iso.torrent` as input.
19+
20+
```bash
21+
asv machine --yes
22+
asv run --quick -E existing:.venv/bin/python --set-commit-hash $(git rev-parse HEAD)
23+
asv continuous origin/master HEAD --factor 1.10 -E existing:.venv/bin/python
24+
```

asv.conf.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"version": 1,
3+
"project": "bencoder.pyx",
4+
"project_url": "https://github.com/whtsky/bencoder.pyx",
5+
"repo": ".",
6+
"branches": ["master"],
7+
"environment_type": "virtualenv",
8+
"pythons": ["3.14"],
9+
"benchmark_dir": "benchmarks",
10+
"env_dir": ".asv/env",
11+
"results_dir": ".asv/results",
12+
"html_dir": ".asv/html",
13+
"matrix": {
14+
"req": {
15+
"cython": [""]
16+
}
17+
},
18+
"build_command": [
19+
"python setup.py build",
20+
"python -m pip wheel -w {build_cache_dir} {build_dir}"
21+
],
22+
"install_command": [
23+
"in-dir={env_dir} python -m pip install --force-reinstall {wheel_file}"
24+
],
25+
"uninstall_command": [
26+
"return-code=any python -m pip uninstall -y bencoder-pyx bencoder.pyx"
27+
]
28+
}

benchmarks/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# ASV benchmark package marker.

benchmarks/codec.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pathlib
2+
3+
from bencoder import bdecode, bencode
4+
5+
6+
class TimeCodec:
7+
def setup(self):
8+
project_root = pathlib.Path(__file__).resolve().parents[1]
9+
torrent_path = project_root / "tests" / "debian-8.3.0-amd64-netinst.iso.torrent"
10+
self.encoded = torrent_path.read_bytes()
11+
self.payload = bdecode(self.encoded)
12+
13+
def time_bencode(self):
14+
bencode(self.payload)
15+
16+
def time_bdecode(self):
17+
bdecode(self.encoded)

0 commit comments

Comments
 (0)