From 6388c11b219656dfed8b6305f4f153e931d40aee Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Tue, 11 Nov 2025 12:09:08 +0100 Subject: [PATCH 1/4] Increase benchmark size --- tests/test_stats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_stats.py b/tests/test_stats.py index 984b460..bd7f015 100644 --- a/tests/test_stats.py +++ b/tests/test_stats.py @@ -371,8 +371,8 @@ def test_stats_benchmark( axis: Literal[0, 1] | None, dtype: type[np.float32 | np.float64], ) -> None: - shape = (10_000, 10_000) if "sparse" in array_type.mod else (1000, 1000) - arr = array_type.random(shape, dtype=dtype) + n = 100_000 if "sparse" in array_type.mod else 10_000 + arr = array_type.random((n, n), dtype=dtype) func(arr, axis=axis) # warmup: numba compile benchmark(func, arr, axis=axis) From 27d706614b152f27d985c9671e3c47151051b7e1 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Tue, 11 Nov 2025 12:16:29 +0100 Subject: [PATCH 2/4] parallel benchmarks --- .github/workflows/ci.yml | 45 ++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bda02e9..d449dec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,12 +18,9 @@ jobs: envs: ${{ steps.get-envs.outputs.envs }} pythons: ${{ steps.get-pythons.outputs.pythons }} steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - filter: blob:none - - name: Install uv - uses: astral-sh/setup-uv@v5 + - uses: actions/checkout@v5 + with: { fetch-depth: 0, filter: "blob:none" } + - uses: astral-sh/setup-uv@v7 - name: Get test environments id: get-envs run: | @@ -53,14 +50,10 @@ jobs: python: "3.13" os: macos-latest steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - filter: blob:none - - uses: astral-sh/setup-uv@v5 + - uses: actions/checkout@v5 + with: { fetch-depth: 0, filter: "blob:none" } + - uses: astral-sh/setup-uv@v7 with: - enable-cache: true - cache-dependency-glob: pyproject.toml python-version: ${{ matrix.env.python }} - name: create environment run: uvx hatch env create ${{ matrix.env.name }} @@ -80,33 +73,27 @@ jobs: name: CPU Benchmarks runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 + with: { fetch-depth: 0, filter: "blob:none" } - uses: actions/setup-python@v5 with: python-version: '3.13' - - uses: astral-sh/setup-uv@v5 - with: - enable-cache: true - cache-dependency-glob: pyproject.toml + - uses: astral-sh/setup-uv@v7 - run: uv pip install --system -e .[test,full] - uses: CodSpeedHQ/action@v3 with: - run: pytest -m benchmark --codspeed + run: pytest -m benchmark --codspeed -n auto token: ${{ secrets.CODSPEED_TOKEN }} import: name: Import Tests runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - filter: blob:none + - uses: actions/checkout@v5 + with: { fetch-depth: 0, filter: "blob:none" } - uses: actions/setup-python@v5 with: python-version: '3.13' - - uses: astral-sh/setup-uv@v5 - with: - cache-dependency-glob: pyproject.toml + - uses: astral-sh/setup-uv@v7 - run: uv pip install --system -e . - run: python -c 'import fast_array_utils as fau; print(fau.__all__)' - run: uv pip install --system -e .[testing] @@ -121,10 +108,8 @@ jobs: env: SKIP: no-commit-to-branch # this CI runs on the main branch steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - filter: blob:none + - uses: actions/checkout@v5 + with: { fetch-depth: 0, filter: "blob:none" } - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} From bf2343e0115fc4feb20a5961e32864421a5d0854 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Tue, 11 Nov 2025 12:20:20 +0100 Subject: [PATCH 3/4] explicit xdist --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index a110131..edc5f27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,6 +50,7 @@ optional-dependencies.test-min = [ "pytest", "pytest-codspeed", "pytest-doctestplus", + "pytest-xdist", ] optional-dependencies.testing = [ "packaging" ] urls.'Documentation' = "https://icb-fast-array-utils.readthedocs-hosted.com/" From 300d0a74aa84d68f5836dde90fe84b52840756e8 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Tue, 11 Nov 2025 13:53:31 +0100 Subject: [PATCH 4/4] only factor 10 --- tests/test_stats.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_stats.py b/tests/test_stats.py index bd7f015..54105b7 100644 --- a/tests/test_stats.py +++ b/tests/test_stats.py @@ -371,8 +371,10 @@ def test_stats_benchmark( axis: Literal[0, 1] | None, dtype: type[np.float32 | np.float64], ) -> None: - n = 100_000 if "sparse" in array_type.mod else 10_000 - arr = array_type.random((n, n), dtype=dtype) + # test with 10M elements will take 20ms for the fastest functions + n_elems, density = 10_000_000, 0.01 + n = int(np.sqrt(n_elems / density if "sparse" in array_type.mod else n_elems)) + arr = array_type.random((n, n), density=density, dtype=dtype) func(arr, axis=axis) # warmup: numba compile benchmark(func, arr, axis=axis)