Tests & debugging

Measure Node.js CPU and memory

Capture a project program, connect costs to sources and export measurements.

In this guidePrepare a bounded captureDistinguish self CPU, total CPU and allocationsKeep the measurements

Prepare a bounded capture#

The profiler really runs the file in the project directory, then stops that process and its children. It does not automatically attach to existing applications. Use a program and data appropriate for a repeatable test.

  1. Open CPU and memory profiler and choose a project Node.js program.
  2. Enter arguments as a JSON array of strings and choose a duration from 1 to 60 seconds.
  3. Start capture, wait for completion or choose Stop.
JSON · Example
["--mode", "sample"]

Distinguish self CPU, total CPU and allocations#

The chart shows RSS and heap over time. The table lists self CPU, inclusive CPU and estimated allocations per function. Filter by name or path and limit to project sources; a verified location opens the file directly.

A capture measures that particular run rather than every real workload. Compare runs with the same data, duration and conditions and consider profiler overhead.

Keep the measurements#

After capture, export CPU, heap or metrics. Process output is available but bounded; it is not a complete log archive. If the program does not start, check its path, arguments and dependencies before repeating the measurement.

Open original image ↗