javascript-profiling

Profile Node.js CPU usage, heap allocation, garbage collection, and event-loop delay with built-in V8 tooling.

2|Updated Feb 26, 2024
One-click install
npx skills add https://github.com/rudolfolah/profiling-code --skill javascript-profiling-rudolfolah
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: javascript-profiling
Source: https://github.com/rudolfolah/profiling-code/tree/main/.claude/skills/javascript-profiling
Command: npx skills add https://github.com/rudolfolah/profiling-code --skill javascript-profiling-rudolfolah

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Node.js performance issues are hard to diagnose without knowing which profiler answers which question. This Skill guides you to the right built-in Node.js and V8 tool for CPU hotspots, allocation churn, retained memory, GC pressure, and event-loop latency, then shows how to capture and interpret the resulting artifacts correctly. ## Core Features & Use Cases - CPU Profiling: Capture .cpuprofile files with node --cpu-prof or scoped node:inspector sessions, including Deno and Bun variants, and load them in Chrome DevTools. - Memory Analysis: Use node --heap-prof for allocation sampling and v8.writeHeapSnapshot() for retained-heap snapshots, with guidance on sampling intervals and snapshot risks. - GC and Event-Loop Diagnostics: Trace garbage collection with --trace-gc, measure scoped operations with performance.measure(), and quantify event-loop delay with monitorEventLoopDelay(). - Use Case: A Jest test suite feels slow. Run node --cpu-prof ./node_modules/jest/bin/jest.js --runInBand, load the profile in Chrome DevTools, and identify the hot call paths before and after a fix. ## Quick Start Ask the AI to profile your Node.js application's CPU usage with node --cpu-prof and explain the hottest call paths in the generated .cpuprofile.

Frequently Asked Questions about javascript-profiling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I profile CPU usage in a Node.js application?

Run your app with node --cpu-prof --cpu-prof-dir=profiles to generate a .cpuprofile file, then load it in Chrome DevTools under Performance > Load profile. Inspect self time and total time separately to find the genuinely expensive call paths.

How do I find a memory leak in Node.js?

Capture heap snapshots with v8.writeHeapSnapshot() and compare snapshots taken around the same application state. Inspect growing retained objects and their retaining paths in Chrome DevTools; allocation sampling with --heap-prof alone does not prove a leak.

What is the difference between --heap-prof and a heap snapshot?

node --heap-prof samples allocation stacks, showing which code allocates the most bytes, including objects later collected. A heap snapshot from v8.writeHeapSnapshot() shows which objects remain reachable at one point in time and what retains them.

Does node --cpu-prof work with Deno and Bun?

Yes, both Deno and Bun expose V8 CPU profiles through --cpu-prof with --cpu-prof-dir and --cpu-prof-name options. However, Node-only heap, GC, and inspector examples do not apply unchanged to those runtimes.

Why does my .heapprofile contain no samples?

Short workloads can finish before the default sampling interval captures anything, producing a valid but empty profile. Lower the interval with --heap-prof-interval=1024 for bounded diagnostic runs, accepting higher overhead and larger artifacts.

How do I measure event-loop delay in Node.js?

Use monitorEventLoopDelay() from node:perf_hooks, enable it before the workload, and read percentiles after letting the observation window span event-loop turns on both sides. Histogram values are nanoseconds, so divide by 1e6 for milliseconds.