Skip to content

Add CodSpeed performance benchmarks for the MPD parser - #1

Open
codspeed-hq[bot] wants to merge 1 commit into
masterfrom
codspeed-wizard-1784455225897
Open

Add CodSpeed performance benchmarks for the MPD parser#1
codspeed-hq[bot] wants to merge 1 commit into
masterfrom
codspeed-wizard-1784455225897

Conversation

@codspeed-hq

@codspeed-hq codspeed-hq Bot commented Jul 19, 2026

Copy link
Copy Markdown

Summary

This PR sets up continuous performance measurement with CodSpeed for dash.js.

It adds a benchmark suite targeting Dash.dependencies.DashParser — the component that turns a raw MPEG-DASH manifest (an XML string) into the JavaScript object tree the player consumes. Parsing runs on every manifest load and every live-manifest refresh, so it is a hot, CPU-bound path and a meaningful target for regression tracking.

What was added

  • benchmarks/ — an isolated benchmark package with its own package.json. It is deliberately kept separate from the root project so the benchmarks can run on a modern Node.js toolchain (vitest) without pulling in the legacy, browser-only build tooling (grunt/jasmine/phantomjs) that no longer installs cleanly on current Node versions.
    • dashParser.bench.js — four benchmarks covering SegmentTemplate-based and SegmentList-based manifests at small and large sizes.
    • loadDash.js — loads the real, unmodified parser source (DashParser, X2JS, ObjectIron, Q) into a Node.js vm context and provides a browser-like environment (window.DOMParser via @xmldom/xmldom), so the benchmarks exercise the actual production code.
    • fixtures.js — generates representative manifests of varying sizes.
    • vitest.config.js — wires in @codspeed/vitest-plugin.
    • README.md — documents the setup and how to run it.
  • .github/workflows/codspeed.yml — runs the benchmarks on CodSpeed in simulation mode on pushes to master, on pull requests, and via manual dispatch. It uses OIDC authentication (id-token: write) and the latest CodSpeedHQ/action@v4.
  • README badge and a Benchmarks section describing how to run the suite locally.

Local verification

The suite was verified locally with the CodSpeed CLI in simulation mode. All four benchmarks are measured and results upload successfully:

Benchmark Time
SegmentList manifest (300 segments/representation) ~212 ms
SegmentList manifest (60 segments/representation) ~39 ms
SegmentTemplate manifest (50 representations) ~11 ms
SegmentTemplate manifest (small) ~3.7 ms

Running locally

cd benchmarks
npm install
npm run bench

Next steps

  • Merge to start tracking parser performance on every PR.
  • Extend coverage to other hot paths (for example segment index handling) as needed.

Set up a vitest + @codspeed/vitest-plugin benchmark suite that measures
DashParser.parse, the MPD manifest parser that runs on every manifest load
and refresh. Benchmarks are isolated in a dedicated benchmarks/ package so
they run on a modern Node.js toolchain, and a GitHub Actions workflow runs
them on CodSpeed in simulation mode.
@codspeed-hq

codspeed-hq Bot commented Jul 19, 2026

Copy link
Copy Markdown
Author

Congrats! CodSpeed is installed 🎉

🆕 4 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 July 19, 2026 10:10
@codspeed-hq
codspeed-hq Bot requested a review from slederer July 19, 2026 10:10
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