Headless benchmark tool to measure DASH.js parser performance across different implementations (XML vs JSON).
This tool measures pure parsing time of the DashParser.parse() function using headless browser automation. It collects:
- β Average parsing time
- β Standard deviation
- β Median, P95, P99 percentiles
- β Min/Max values
- β Coefficient of variation for consistency analysis
The benchmark measures ONLY the execution time of:
const parsedManifest = parserInstance.parse(manifestData);This includes:
- XML/JSON string parsing
- Node processing (for XML)
- Type conversions (matchers)
- ObjectIron inheritance
- Array organization
It excludes:
- Network requests
- Manifest loading
- Player initialization
- Event handling
npm installCopy your dash.js builds to the builds/ directory:
cp ../dash.js/dist/dash.all.debug.js builds/dash-xml.js
cp ../dash.js/dist/dash.all.debug-json.js builds/dash-json.js
cp ../dash.js/dist/dash.all.debug-json-optimized.js builds/dash-json-optimized.jsCompare XML vs JSON (standard):
npm run benchmark -- xml jsonCompare XML vs JSON (optimized):
npm run benchmark -- xml json-optimizedTest a single build:
npm run benchmark -- xmldash-parser-benchmark/
βββ package.json # Dependencies and scripts
βββ config.json # Build aliases and configuration
βββ index.html # Browser test page
βββ benchmark.js # Main benchmark entry point
βββ runner.js # Benchmark runner with server
βββ README.md # This file
βββ src/ # Benchmark modules
βββ builds/ # Place your dash.js builds here
β βββ dash-xml.js
β βββ dash-json.js
β βββ dash-json-optimized.js
βββ manifests/ # Test manifests
β βββ test_pic.mpd
β βββ test_pic.json
βββ results/ # Generated reports
βββ pure-parsing-report-*.json
This tool has two simple modes:
Run automated benchmarks locally using Puppeteer in headless mode. Results are saved automatically.
npm run benchmark -- <build1> [build2] [build3]Examples:
# Compare two builds
npm run benchmark -- xml json
# Compare three builds
npm run benchmark -- xml json json-optimized
# Test single build
npm run benchmark -- xmlUse this mode for:
- Quick automated testing
- CI/CD pipelines
- Consistent reproducible results
Start an HTTP server that allows you to run benchmarks from any browser (local or remote). Results are saved automatically to the server.
npm run serverThen simply navigate to the root URL:
- Local testing:
http://localhost:8080 - Remote testing (via ngrok):
https://your-ngrok-url.app
You'll see an interactive page with buttons for each build configuration. Just click/tap a button to start the benchmark - no need to manually type query parameters!
Advanced usage (direct URL with parameters): You can still use direct URLs if needed:
http://localhost:8080/index.html?build=/builds/dash-xml.js&manifest=/manifests/test_pic.mpd&iterations=100
Use this mode for:
- Testing on real devices (phones, tablets, TVs)
- Visual debugging
- Testing in different browsers (Safari, Chrome, Firefox)
- Remote testing via ngrok
- Easy one-click benchmark execution
Remote Testing Setup:
-
Start the server:
npm run server
-
In another terminal, start ngrok:
ngrok http 8080
-
Use the ngrok URL from any device to run benchmarks
All results will be automatically saved to the results/ folder on the server.
The build aliases are defined in config.json:
xml- XML Parserjson- JSON Parser (Standard)json-optimized- JSON Parser (Optimized)
Edit config.json to customize your benchmarks:
{
"iterations": 100,
"buildAliases": {
"xml": {
"name": "XML Parser",
"path": "/builds/dash-xml.js",
"manifest": "/manifests/test_pic.mpd"
},
"json": {
"name": "JSON Parser (Standard)",
"path": "/builds/dash-json.js",
"manifest": "/manifests/test_pic.json"
},
"json-optimized": {
"name": "JSON Parser (Optimized)",
"path": "/builds/dash-json-optimized.js",
"manifest": "/manifests/test_pic.json"
}
}
}iterations: Number of parsing iterations per testbuildAliases: Object mapping alias names to build configurations- Each alias contains:
name: Display name for the buildpath: Path to the build file (relative to project root)manifest: Path to the manifest file to use with this build
- Each alias contains:
To add a new build to test:
- Copy your build file to
builds/directory - Add a new entry to
buildAliasesinconfig.json:
"my-custom-build": {
"name": "My Custom Build",
"path": "/builds/dash-custom.js",
"manifest": "/manifests/test_pic.json"
}- Run it:
npm run benchmark -- xml my-custom-buildA detailed JSON report is saved in results/ after each benchmark run:
{
"timestamp": "2025-12-22T20:12:18.992Z",
"measurementType": "pure-parsing",
"description": "Measures only the DashParser.parse() function execution time",
"source": "remote-browser",
"userAgent": "Mozilla/5.0...",
"results": [
{
"build": "XML Parser",
"manifest": "test_pic.mpd",
"stats": {
"avg": 1.234,
"stdDev": 0.123,
"median": 1.200,
"p95": 1.456,
...
}
}
]
}- Average: Mean parsing time across all iterations
- Standard Deviation (Std Dev): Measure of variation in parsing times
- Median (P50): Middle value when sorted
- P75/P90/P95/P99: Percentile values (e.g., P95 means 95% of runs were faster)
- Coefficient of Variation (CV): Std Dev / Average Γ 100%
- CV < 5%: Excellent consistency
- CV < 10%: Good consistency
- CV < 20%: Moderate variance
- CV β₯ 20%: High variance (may need more iterations)
Make sure the alias is defined in config.json under buildAliases.
- Ensure build files exist in
builds/directory - Check that paths in
config.jsonstart with/builds/ - Verify the dash.js build is complete and valid
- Make sure your dash.js build includes
DashParserandFactoryMaker - Try using the debug build instead of minified version
- Increase
iterationsinconfig.json - Close other applications to reduce system load
- Run benchmark multiple times and average results
- Make sure server is running with
npm run server - Check that ngrok is pointing to port 8080
- Verify firewall is not blocking the port
- Server listens on
0.0.0.0to accept remote connections
- Node.js 16+
- Chrome/Chromium (installed automatically by Puppeteer)
- ngrok (optional, for remote testing)
MIT