Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add CodSpeed to the project #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
pull_request:

permissions:
contents: write
Expand All @@ -12,9 +13,6 @@ jobs:
benchmark:
name: Run pytest-benchmark
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- name: Checkout Code
uses: actions/checkout@v4
Expand All @@ -23,27 +21,15 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: 3.12
- name: Install requirements (Python 3)
run: |
pip install -r requirements/ci.txt
pip install -r requirements/ci-3.11.txt
- name: Install pypdf
run: |
pip install .
- name: Run benchmark
run: |
pytest tests/bench.py --benchmark-json output.json
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
- name: Run benchmarks
uses: CodSpeedHQ/action@v2
with:
name: Python Benchmark with pytest-benchmark
tool: 'pytest'
output-file-path: output.json
# Use personal access token instead of GITHUB_TOKEN due to https://github.community/t/github-action-not-triggering-gh-pages-upon-push/16096
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@MartinThoma'
token: ${{ secrets.CODSPEED_TOKEN }}
run: pytest tests/bench.py --codspeed
43 changes: 14 additions & 29 deletions requirements/ci-3.11.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --config=pyproject.toml --output-file=requirements/ci-3.11.txt requirements/ci.in
#
attrs==23.1.0
# via flake8-bugbear
cffi==1.16.0
# via pytest-codspeed
coverage[toml]==7.3.0
# via
# -r requirements/ci.in
# pytest-cov
execnet==2.0.2
# via pytest-xdist
flake8==6.1.0
# via
# -r requirements/ci.in
# flake8-bugbear
# flake8-print
flake8-bugbear==23.7.10
# via -r requirements/ci.in
flake8-implicit-str-concat==0.4.0
# via -r requirements/ci.in
flake8-print==5.0.0
# via -r requirements/ci.in
filelock==3.13.4
# via pytest-codspeed
fpdf2==2.4.1
# via -r requirements/ci.in
iniconfig==2.0.0
# via pytest
mccabe==0.7.0
# via flake8
mypy==1.5.1
# via -r requirements/ci.in
mypy-extensions==1.0.0
Expand All @@ -43,24 +32,23 @@ pluggy==1.2.0
# via pytest
py-cpuinfo==9.0.0
# via pytest-benchmark
pycodestyle==2.11.0
# via
# flake8
# flake8-print
pycparser==2.22
# via cffi
pycryptodome==3.18.0
# via -r requirements/ci.in
pyflakes==3.1.0
# via flake8
pytest==7.4.0
# via
# -r requirements/ci.in
# pytest-benchmark
# pytest-codspeed
# pytest-cov
# pytest-socket
# pytest-timeout
# pytest-xdist
pytest-benchmark==4.0.0
# via -r requirements/ci.in
pytest-codspeed==2.2.1
# via -r requirements/ci.in
pytest-cov==4.1.0
# via -r requirements/ci.in
pytest-socket==0.6.0
Expand All @@ -71,15 +59,12 @@ pytest-xdist==3.3.1
# via -r requirements/ci.in
pyyaml==6.0.1
# via -r requirements/ci.in
ruff==0.0.290
# via -r requirements/ci.in
typeguard==4.1.2
# via -r requirements/ci.in
types-dataclasses==0.6.6
# via -r requirements/ci.in
types-pillow==10.0.0.2
# via -r requirements/ci.in
typing-extensions==4.7.1
# via
# mypy
# typeguard
# via mypy

# The following packages are considered to be unsafe in a requirements file:
# setuptools
1 change: 1 addition & 0 deletions requirements/ci.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pillow
pycryptodome
pytest
pytest-benchmark
pytest-codspeed
pytest-socket
pytest-timeout
pytest-xdist
Expand Down
5 changes: 3 additions & 2 deletions tests/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def text_extraction(pdf_path):


def test_text_extraction(benchmark):
file_path = SAMPLE_ROOT / "009-pdflatex-geotopo/GeoTopo.pdf"
file_path = SAMPLE_ROOT / "004-pdflatex-4-pages/pdflatex-4-pages.pdf"
benchmark(text_extraction, file_path)


Expand Down Expand Up @@ -201,7 +201,8 @@ def image_new_property(data):
["/TPL11", "/Image30"],
["/TPL12", "/Image30"],
]
assert len(reader.pages[0].images.items()) == 36
# commented out to speed up the benchmark
# assert len(reader.pages[0].images.items()) == 36
assert reader.pages[0].images[0].name == "I0.png"
assert len(reader.pages[0].images[-1].data) == 15168
assert reader.pages[0].images["/TPL1", "/Image5"].image.format == "JPEG"
Expand Down