@contrast/perf
v1.2.2
Published
Performance measurement
Downloads
77,675
Maintainers
Keywords
Readme
Perf
The perf module is intended for developers to be able to measure the performance of code.
Although the code is relatively efficient, it is not intended to be used in production code.
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
To enable perf, the environment variable CSI_PERF
must be set to 1
.
The logging interval can be set with the environment variable CSI_PERF_INTERVAL
. The value is in milliseconds. The default is 60000, but after startup logging only occurs every 5 intervals. This is to avoid logging but should change if the request generators all complete in less than a minute.
The log is written to agent-perf.jsonl
in the current working directory.
Log format
The log is one JSON object per line (JSONL).
Future
Histograms that store complex objects?