@contrast/perf
Performance measurement for developers working on the Contrast Node.js agent. It's meant for development and testing, though it is light enough to use when troubleshooting a performance issue in production.
Design goals
The primary design goal of the perf module is that it not introduce any cost when it is not in use. Practically, this is impossible in an interpreted language, so perf is designed to have no cost after startup when it is not in use. Perf does not introduce any cost after startup if it is not enabled.
A secondary design goal is that perf is efficient enough that, if desired, it could be used in production code in order to troubleshoot a performance issue. To this end, minimal aggregation and no analysis is performed at runtime. The perf log is very simple and can be analyzed offline.
Usage
Set the environment variable CSI_PERF to 1 to enable perf.
CSI_PERF_INTERVAL sets the timer interval in milliseconds (default 60000).
Startup timings are written during the first few intervals, and the full set of
timings is written every fifth interval after that (every 5 minutes by
default). The timer doesn't keep the process alive, so a short run may exit
before anything is logged. Lower the interval for short runs.
The log is written to agent-perf.jsonl in the current working directory.
Log format
The log is one JSON object per line (JSONL).