Part of the no-pro mono-repo.
npm install @no-pro/runtime
const { startProfiling } = require('@no-pro/runtime')
...
async function someFunction () {
const stopProfiling = await startProfiling()
// run some code to be profiled
const profile = await stopProfiling()
// the profile variable now contains JSON-able profile data
}
The package exports the following properties and functions:
The value of this property is the version of this npm package installed.
This function will start the CPU profiler. It resolves to an async function which is used to stop the CPU profile and return the profile result.
The "stop" async function resolved by this function takes no arguments. It stops the profile and returns the profile data as a JSON-able object.
The optional options
argument is an object which can contain the following
properties:
-
scripts
If set to a truthy value, the source code of the modules that were profiled will be returned with the result. Default:
false
-
metaData
If set to a truthy value, some meta-data about the process will be returned with the result. Default:
true
-
metrics
If set to a truthy value, some metrics gathered during the profile will be returned with the result. Default:
true
-
samplingInterval
Set to the CPU profiler sampling interval, in microseconds (1000 microseconds = 1 millisecond; 1000 milliseconds = 1 second). Default:
10
-
writeProfile
The value should be a string or function. If a string, the profile will be written to the specified file. If a function, the function will be invoked as an async function, and passed the profile object to be written.
See the file CHANGELOG.md.
See the root of the no-pro mono-repo.