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

Add codspeed benchmarks #1029

Closed
wants to merge 6 commits into from
Closed
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
83 changes: 83 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,89 @@ jobs:
if: ${{ matrix.os == 'ubuntu' }}
uses: aio-libs/[email protected]

benchmark:
name: Benchmark
needs:
- build-pure-python-dists # transitive, for accessing settings
- build-wheels-for-tested-arches
- pre-setup # transitive, for accessing settings
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Retrieve the project source from an sdist inside the GHA artifact
uses: re-actors/checkout-python-sdist@release/v2
with:
source-tarball-name: >-
${{ needs.build-pure-python-dists.outputs.sdist-filename }}
workflow-artifact-name: >-
${{ needs.pre-setup.outputs.dists-artifact-name }}
- name: Download distributions
uses: actions/download-artifact@v4
with:
path: dist
pattern: ${{ needs.pre-setup.outputs.dists-artifact-name }}*
merge-multiple: true

- name: Setup Python 3.12
id: python-install
uses: actions/setup-python@v5
with:
python-version: 3.12
cache: pip
cache-dependency-path: requirements/*.txt
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
path: requirements/pytest.txt
- name: Determine pre-compiled compatible wheel
env:
# NOTE: When `pip` is forced to colorize output piped into `jq`,
# NOTE: the latter can't parse it. So we're overriding the color
# NOTE: preference here via https://no-color.org.
# NOTE: Setting `FORCE_COLOR` to any value (including 0, an empty
# NOTE: string, or a "YAML null" `~`) doesn't have any effect and
# NOTE: `pip` (through its verndored copy of `rich`) treats the
# NOTE: presence of the variable as "force-color" regardless.
#
# NOTE: This doesn't actually work either, so we'll resort to unsetting
# NOTE: in the Bash script.
# NOTE: Ref: https://github.com/Textualize/rich/issues/2622
NO_COLOR: 1
id: wheel-file
run: >
echo -n path= | tee -a "${GITHUB_OUTPUT}"


unset FORCE_COLOR


python
-X utf8
-u -I
-m pip install
--find-links=./dist
--no-index
'${{ env.PROJECT_NAME }}'
--force-reinstall
--no-color
--no-deps
--only-binary=:all:
--dry-run
--report=-
--quiet
| jq --raw-output .install[].download_info.url
| tee -a "${GITHUB_OUTPUT}"
shell: bash
- name: Self-install
run: python -Im pip install '${{ steps.wheel-file.outputs.path }}'
- name: Run benchmarks
uses: CodSpeedHQ/action@v3
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: python -Im pytest --no-cov -vvvvv --codspeed

test-summary:
name: Tests status
if: always()
Expand Down
5 changes: 5 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ disable_error_code =
[mypy-test_multidict]
disable_error_code = call-arg

[mypy-test_multidict_benchmarks]
disable_error_code =
no-any-unimported,
misc,

[mypy-test_mutable_multidict]
disable_error_code =
arg-type,
Expand Down
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ repos:
- types-docutils
- lxml # dep of `--txt-report`, `--cobertura-xml-report` & `--html-report`
- pytest
- pytest_codspeed
- Sphinx >= 5.3.0
args:
- --python-version=3.13
Expand All @@ -128,6 +129,7 @@ repos:
- types-docutils
- lxml # dep of `--txt-report`, `--cobertura-xml-report` & `--html-report`
- pytest
- pytest_codspeed
- Sphinx >= 5.3.0
args:
- --python-version=3.11
Expand All @@ -142,6 +144,7 @@ repos:
- types-docutils
- lxml # dep of `--txt-report`, `--cobertura-xml-report` & `--html-report`
- pytest
- pytest_codspeed
- Sphinx >= 5.3.0
args:
- --python-version=3.9
Expand All @@ -156,6 +159,7 @@ repos:
- types-docutils
- lxml # dep of `--txt-report`, `--cobertura-xml-report` & `--html-report`
- pytest
- pytest_codspeed
- Sphinx >= 5.3.0
args:
- --python-version=3.8
Expand Down
1 change: 0 additions & 1 deletion multidict/_multidict_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def GenericAlias(cls):


class istr(str):

"""Case insensitive str."""

__is_istr__ = True
Expand Down
3 changes: 2 additions & 1 deletion requirements/pytest.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pytest==8.3.3
pytest-cov==5.0.0
pytest-codspeed==2.2.1
pytest-cov==5.0.0
Loading
Loading