Tests & debugging

Measure Node.js CPU and memory

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

In this guideBefore you start · PremiumMeasure a project data transformationDistinguish self CPU, total CPU and allocationsKeep the measurements

Before you start · Premium#

This guide covers tools included in Code Weaver Premium. Sign in to your account in the IDE and check that Premium is active. Without Premium you can still browse, search, edit and save your files.

Measure a project data transformation#

The profiler measures process work. Self CPU is time in the function; inclusive CPU includes its calls. Heap is memory managed by JavaScript; RSS is resident process memory. For comparable runs, use the same program, data and duration.

A capture actually starts the Node.js file in the project folder and stops that process and its children when finished. Example: scripts/import-preview.mjs transforms a copy of sample data without updating the database.

  1. Select the project folder and open CPU and memory profiler, also available through Ctrl+Shift+P.
  2. Under Node.js program, enter the file, for example scripts/import-preview.mjs.
  3. Fill in JSON arguments with an array of strings, for example ["--mode", "sample"], and choose Duration (s), for example 5.
  4. Click Start capture and wait for completion; Stop lets you finish earlier.
  5. Enable Project code only, sort by Self CPU or Allocations and open a source location from the table.
  6. Read the memory chart and Process output. Export CPU, Heap or Metrics to keep the measurement.
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 ↗