Add CodSpeed performance benchmarks and CI workflow#753
Open
codspeed-hq[bot] wants to merge 1 commit into
Open
Add CodSpeed performance benchmarks and CI workflow#753codspeed-hq[bot] wants to merge 1 commit into
codspeed-hq[bot] wants to merge 1 commit into
Conversation
Author
Congrats! CodSpeed is installed 🎉
You will start to see performance impacts in the reports once the benchmarks are run from your default branch.
|
|
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.


Summary
This PR sets up continuous performance measurement with CodSpeed for AudioMuse-AI. It adds a pytest-based benchmark suite covering dependency-light hot paths, a GitHub Actions workflow to run those benchmarks on every push and pull request, and a CodSpeed badge in the README.
What was added
test/benchmarks/— a new benchmark suite built onpytest-codspeed:test_bench_sanitization.py— benchmarks the string/JSON sanitization helpers insanitization.pythat run on every database write and API response (NUL/control-character stripping, nested-JSON sanitization, and numpy-to-native conversion), using realistic payload sizes.test_bench_playlist_ordering.py— benchmarks the pure sonic-ordering distance helpers intasks/playlist_ordering.py(_key_distance,_composite_distance) that drive the greedy nearest-neighbour walk used when sequencing playlists.requirements.txt— minimal dependencies for the suite (numpypinned to1.26.4to matchrequirements/common.txt, pluspytestandpytest-codspeed)..github/workflows/codspeed.yml— runs the benchmarks in CodSpeed'ssimulation(instrumentation) mode onubuntu-latest, usingCodSpeedHQ/action@v4with OpenID Connect authentication.README.md— added the CodSpeed badge alongside the existing badges.Approach
The benchmarks intentionally target self-contained, CPU-bound functions that can be imported without the project's heavy runtime dependencies (sklearn, torch, redis, a live database, etc.). This keeps the CI job fast and stable while still tracking code that runs on real hot paths. The existing repository conventions are respected: every new file carries the AGPL house header and a
Main Features:docstring, and all source is plain ASCII, so the repo's header/emoji/em-dash guard tests continue to pass.simulationmode is used because it is the recommended mode for CPU-bound Python code: it provides deterministic, hardware-agnostic measurements (sub-1% variance) and automatic flamegraphs, so no macro runners are required.Verification
The suite was run locally through the CodSpeed CLI in simulation mode and all 6 benchmarks pass and report results successfully.
Next steps