Add CodSpeed performance benchmarks#1
Merged
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 downcloud.
The project is a Bun + TypeScript CLI whose hot paths are mostly I/O (network, ffmpeg), but it contains several CPU-bound helpers that are good candidates for tracking: SoundCloud
client_iddiscovery (regex scanning of homepage HTML and minified asset bundles) and waveform processing (downsampling, normalizing, and ASCII rendering of amplitude samples).To benchmark this logic without importing the Bun-specific CLI entrypoint, the pure functions were extracted into a new
lib.tsmodule, andindex.tswas refactored to consume them. This keeps a single source of truth so the benchmarks track the real code.Changes
lib.ts(new): Pure, side-effect-free helpers extracted fromindex.ts—extractAssetUrls,findClientIdInChunk,compressWaveform,normalizeWaveform,renderAsciiWaveform,originalArtworkUrl, andformatTime.index.ts: Refactored to import and use the helpers fromlib.ts. Behavior is unchanged (verified the CLI help and type-checking still pass).bench/lib.bench.ts(new): Vitest benchmarks covering client_id discovery, waveform processing (1800 and 20000 sample inputs), and metadata helpers, using realistically sized synthetic inputs.vitest.config.ts(new): Registers the@codspeed/vitest-plugin.package.json/bun.lock/bun.nix: Addedvitestand@codspeed/vitest-pluginas dev dependencies..github/workflows/codspeed.yml(new): GitHub Actions workflow that installs Bun, installs dependencies, and runs the benchmarks through the CodSpeed action in simulation mode using OIDC authentication.README.md: Added the CodSpeed badge.Local verification
All 8 benchmarks run successfully under CodSpeed simulation mode locally (
codspeed run --mode simulation -- bunx vitest bench --run), and results upload and link to theyaaaarn/downcloudrepository.Next steps
master.