Skip to content

Latest commit

 

History

History
101 lines (59 loc) · 2.7 KB

README.md

File metadata and controls

101 lines (59 loc) · 2.7 KB

no-pro runtime - core profiling library for node.js

NPM version

Part of the no-pro mono-repo.

install

npm install @no-pro/runtime

quick start

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
}

usage

The package exports the following properties and functions:

version

The value of this property is the version of this npm package installed.

async startProfiling([options])

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.

changelog

See the file CHANGELOG.md.

license / contributing / etc

See the root of the no-pro mono-repo.