mirror of
https://github.com/mblanke/dev-backbone-template.git
synced 2026-03-01 05:50:22 -05:00
1.2 KiB
1.2 KiB
Performance Profiling (Bun/Node)
Use this skill when:
- a hot path feels slow
- CPU usage is high
- you suspect accidental O(n²) or repeated work
- you need evidence before optimizing
Bun CPU profiling
Bun supports CPU profiling via --cpu-prof (generates a .cpuprofile you can open in Chrome DevTools).
Upcoming: bun --cpu-prof-md <script> outputs a CPU profile as Markdown so LLMs can read/grep it easily.
Workflow (Bun)
- Run the workload with profiling enabled
- Today:
bun --cpu-prof ./path/to/script.ts - Upcoming:
bun --cpu-prof-md ./path/to/script.ts
- Today:
- Save the output (or
.cpuprofile) into./profiles/with a timestamp. - Ask the Reviewer agent to:
- identify the top 5 hottest functions
- propose the smallest fix
- add a regression test or benchmark
Node CPU profiling (fallback)
node --cpu-prof ./script.jswrites a.cpuprofilefile.- Open in Chrome DevTools → Performance → Load profile.
Rules
- Optimize based on measured hotspots, not vibes.
- Prefer algorithmic wins (remove repeated work) over micro-optimizations.
- Keep profiling artifacts out of git unless explicitly needed (use
.gitignore).