Commit Graph

1 Commits

Author SHA1 Message Date
Jimmy Lai a39366938a chore: add dev boot profiling and benchmark scripts (#87940)
## Summary

Development scripts for profiling and benchmarking Next.js dev server boot time.

### Benchmarking Scripts
- `benchmark-boot-time.sh` - Wall-clock benchmarking with two metrics:
  - **Listen time**: When TCP port accepts connections
  - **Ready time**: When first HTTP request succeeds
- `benchmark-next-dev-boot.js` - Multi-iteration benchmarking with statistics (median, p95, stddev)

### Profiling Scripts
- `profile-next-dev-boot.js` - CPU profiling infrastructure using V8 inspector
- `analyze-profile.js` - Analyze CPU profiles to identify hot modules by CPU time

### Analysis Scripts
- `analyze-dev-server-bundle.js` - Bundle analyzer for dev server (generates treemap report)
- `trace-cli-startup.js` - Module loading trace to identify slow imports

## Usage

```bash
# Benchmark dev server boot time (5 runs by default)
./scripts/benchmark-boot-time.sh

# Multi-iteration benchmark with stats
node scripts/benchmark-next-dev-boot.js --iterations 10

# Generate CPU profile
node scripts/profile-next-dev-boot.js

# Analyze profile output
node scripts/analyze-profile.js .next/cpu-profiles/*.cpuprofile

# Analyze dev server bundle
node scripts/analyze-dev-server-bundle.js --open
```

## Test Plan
- [x] Run `./scripts/benchmark-boot-time.sh` locally
- [x] Verify scripts execute without errors
2026-01-06 12:18:01 +01:00