Skip to content

Add CodSpeed performance benchmarks#1

Merged
yaaaarn merged 1 commit into
masterfrom
codspeed/wizard-1781648764669
Jun 16, 2026
Merged

Add CodSpeed performance benchmarks#1
yaaaarn merged 1 commit into
masterfrom
codspeed/wizard-1781648764669

Conversation

@codspeed-hq

@codspeed-hq codspeed-hq Bot commented Jun 16, 2026

Copy link
Copy Markdown

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_id discovery (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.ts module, and index.ts was 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 from index.tsextractAssetUrls, findClientIdInChunk, compressWaveform, normalizeWaveform, renderAsciiWaveform, originalArtworkUrl, and formatTime.
  • index.ts: Refactored to import and use the helpers from lib.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: Added vitest and @codspeed/vitest-plugin as 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 the yaaaarn/downcloud repository.

Next steps

  • Merge this PR so the baseline is recorded on master.
  • Subsequent pull requests will automatically get performance reports comparing against the baseline.
  • Consider adding more benchmarks as new CPU-bound logic is introduced.

@codspeed-hq

codspeed-hq Bot commented Jun 16, 2026

Copy link
Copy Markdown
Author

Congrats! CodSpeed is installed 🎉

🆕 8 new benchmarks were detected.

You will start to see performance impacts in the reports once the benchmarks are run from your default branch.

Detected benchmarks


Open in CodSpeed

@codspeed-hq codspeed-hq Bot marked this pull request as ready for review June 16, 2026 22:32
@yaaaarn yaaaarn merged commit de00a6c into master Jun 16, 2026
2 checks passed
@yaaaarn yaaaarn deleted the codspeed/wizard-1781648764669 branch June 16, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant