Add CodSpeed performance benchmarks and CI workflow - #984
Merged
Conversation
Contributor
Author
Collaborator
Add a concurrency group so pushing new commits to an open PR cancels the previous, still-running benchmark job instead of letting both run to completion (~15 min each under CPU simulation). Push events to main are excluded from cancellation, since each one records a new CodSpeed baseline and losing one would create a gap in the history.
Only run the CodSpeed job on pull requests once a maintainer adds the runcodespeed label, after reviewing the PR. It keeps re-running on further pushes to that PR for as long as the label stays attached; removing the label goes back to no auto-runs. Doc-only changes (docs/**, *.md, *.rst, the JOSS paper) are excluded from the trigger entirely, since they can't affect performance. Pushes to main and workflow_dispatch runs are unaffected: both still run unconditionally, since every main push records a CodSpeed baseline.
This was referenced Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
Continuous performance measurement for Feature-engine with CodSpeed, so performance regressions are caught on pull requests instead of after a release.
Benchmark suite (
benchmarks/)109 benchmarks written with
pytest-codspeed, one module per transformer family.fitandtransformare benchmarked separately because their performance profiles are very different (learning parameters vs. applying them):test_imputation.pytest_encoding.pytest_discretisation.pytest_outliers.pytest_transformation.pytest_creation.pytest_datetime.pytest_timeseries.pytest_selection.pytest_variable_handling.pyfind_*/check_*helpers, which run inside every transformer'sfittest_pipeline.pyMatchVariablesandMatchCategoriesDetails worth noting:
conftest.pyfixtures (numerical, strictly positive, bounded, categorical with rare labels, and datetime variables, with a variant containing missing values). Data generation therefore never lands inside a measured section.MathFeatures).FutureWarningand will not break at the 2.1.0 removals.CI workflow (
.github/workflows/codspeed.yml)Runs on pushes to
main, on pull requests, and onworkflow_dispatch(needed by CodSpeed to backfill initial data). It usesCodSpeedHQ/action@v5insimulationmode onubuntu-latest, with OIDC authentication (id-token: write), so no token secret is required.Simulation mode was chosen because the benchmarks are CPU-bound: it gives deterministic, hardware-agnostic measurements with under 1% variance and produces flame graphs for each benchmark.
Other changes
pyproject.toml: addedtestpaths = ["tests"]to the pytest configuration. Without it, a barepytest(as used by thecodecovtox environment) would also collectbenchmarks/, which needspytest-codspeedinstalled. Runningpytest benchmarks/explicitly still works.README.md: added the CodSpeed badge to the Testing row.Verification
The suite was run locally in the same mode as CI:
All 109 benchmarks pass, and a plain
pytest benchmarks/ --codspeedwalltime run completes in about 7 minutes. Expect the CI job to take roughly 15 minutes, most of it CPU simulation overhead.flake8,blackandisortwere run on the new files.Next steps
mainbranch gets a performance baseline. Until then, PR reports have nothing to compare against.benchmarks/README.md.