Performance Benchmarking - Quick Start
Get up and running with performance benchmarking in minutes.
π First Time Setup
Step 1: Install Lighthouse CI
npm install -g @lhci/cliThis installs the Lighthouse CI tool globally, which is required for running benchmarks.
Step 2: Verify Installation
lhci --versionYou should see a version number like 0.13.x.
π Running Benchmarks Locally
Full Benchmark Suite
# 1. Build your application
npm run build
# 2. Start the production server (in a separate terminal)
npm run start
# 3. Wait for server to be ready (you'll see "ready on http://localhost:3000")
# 4. In another terminal, run benchmarks
npm run benchmark:lighthouse # Lighthouse metrics
npm run benchmark:bundle # Bundle size
npm run benchmark:memory # Memory usage
# 5. Parse results and generate report
npm run benchmark:parse
npm run benchmark:report
# 6. Check against budgets
npm run benchmark:checkQuick Bundle Analysis (No server needed)
# Just analyze bundle size after building
npm run build
npm run analyze:bundleπ― What Each Command Does
| Command | What It Does | Requires Build | Requires Server |
|---|---|---|---|
npm run benchmark:lighthouse | Runs Lighthouse on your app (5 runs) | β | β |
npm run benchmark:bundle | Analyzes bundle sizes | β | β |
npm run benchmark:memory | Measures memory usage | β | β |
npm run benchmark:parse | Parses Lighthouse JSON results | β | β |
npm run benchmark:report | Generates comprehensive report | β | β |
npm run benchmark:check | Validates against budgets | β | β |
npm run analyze:bundle | Quick bundle analysis | β | β |
π Viewing Results
Console Output
All commands print results to the console:
npm run benchmark:checkOutput:
π° Performance Budget Check
Budget Status:
β
First Contentful Paint 1245ms (budget: 1800ms)
β
Largest Contentful Paint 1876ms (budget: 2500ms)
β
Cumulative Layout Shift 0.05 (budget: 0.1)
...JSON Reports
Results are saved in benchmark-results/:
lighthouse-results.json- Full Lighthouse databundle-size.json- Bundle analysismemory-benchmark.json- Memory metricsperformance-report.json- Combined report
HTML Reports
Lighthouse generates HTML reports in .lighthouse-benchmark/:
# Open in browser
start .lighthouse-benchmark/*/lhr-*.htmlβ οΈ Troubleshooting
Error: 'lhci' is not recognized
Problem: Lighthouse CI not installed globally
Solution:
npm install -g @lhci/cliError: startServerCommand failed
Problem: Server isn't starting or listening on port 3000
Solution:
- Make sure you've built the app:
npm run build - Manually start the server in another terminal:
npm run start - Wait for "ready on http://localhost:3000 (opens in a new tab)"
- Run
npm run benchmark:lighthousein the first terminal
Error: Navigation timeout
Problem: Server is slow to respond or pages don't exist
Solution:
- Check that all URLs in
lighthouserc.benchmark.jsonexist - Increase timeout in config if needed
- Make sure server is running in production mode
Zero Metrics (0ms, 0/100)
Problem: Benchmarks haven't been run yet
Solution:
# Full sequence
npm run build
npm run start # in another terminal
npm run benchmark:lighthouse
npm run benchmark:parse
npm run benchmark:report
npm run benchmark:checkπ― Performance Budgets
Current budgets (edit in scripts/check-performance-budget.js):
| Metric | Budget |
|---|---|
| FCP | β€1.8s |
| LCP | β€2.5s |
| CLS | β€0.1 |
| TBT | β€200ms |
| Speed Index | β€3.4s |
| TTI | β€3.8s |
| Performance Score | β₯95/100 |
| Bundle Size | β€250 KB (gzipped) |
π Automated Monitoring (CI/CD)
Benchmarks run automatically in GitHub Actions:
- β
On every push to
main - β
On every PR to
main/develop - β Daily at 2 AM UTC
- β Manual workflow dispatch
No local setup needed for CI/CD - it runs automatically!
π‘ Tips
For Development
# Quick bundle check during development
npm run build
npm run analyze:bundleBefore Committing
# Verify performance hasn't regressed
npm run build
npm run start # separate terminal
npm run benchmark:lighthouse
npm run benchmark:checkFor CI/CD Testing
# Simulate what runs in GitHub Actions
npm run build
npm run benchmark
npm run benchmark:parse
npm run benchmark:report
npm run benchmark:checkπ More Information
For detailed documentation, see:
- Performance Benchmarking Guide - Complete guide
.github/workflows/performance-benchmark.yml- GitHub Actions workflow
β Quick Checklist
First time setup:
- Install Lighthouse CI:
npm install -g @lhci/cli - Verify installation:
lhci --version
Before running benchmarks:
- Build the app:
npm run build - Start the server:
npm run start(separate terminal) - Wait for server ready message
Run benchmarks:
-
npm run benchmark:lighthouse -
npm run benchmark:parse -
npm run benchmark:report -
npm run benchmark:check
Review results:
- Check console output
- Review
benchmark-results/*.json - Open HTML reports (optional)
π You're all set! The framework maintains 100/100 Lighthouse scores with automated monitoring.