small promise interface to v8-profiler functions
npm i --save nprof
var nprof = require('nprof');
nprof.takeMemorySnapshot('/tmp/snapshots')
.then((info) => {})
.catch((error) => {});
nprof.cpuProfile('/tmp/snapshots', 2000)
.then((info) => {})
.catch((error) => {});
- snapshotPath - path to directory (nprof generate filenames)
- options
- filepath - set this option with filepath, if you need your own filename
take memory snapshot and save to snapshotPath
${snapshotPath}/v8.cpu.2016-09-20T13-56-53-936.cpuprofile'
- snapshotPath - path to directory (nprof generate filenames, see)
- timeout - timeout in ms
- options
- filepath - set this option with filepath, if you need your own filepath and filename
start cpu profiling, stop after timeout and save to snapshotPath
${snapshotPath}/v8.cpu.2016-09-20T13-56-53-93.timeout.' + timeout + '.cpuprofile'
start cpu profiling
stop cpu proflile
save profile to file
- profile - profile object
- snapshotPath - path to directory (nprof generate filenames)
- options
- filepath - set this option with filepath, if you need your own filename
express.js profiling helper
// logger is you logger with info, warn and error methods
var nprofRegister = require('nprof/express/register');
var app = express();
var nprofConfig = {
snapshotPath: '/tmp/snapshots'
};
nprofRegister(logger, app, nprofConfig);
- timeout - profile timeout, length of profiling in ms, default = 5000
profile CPU, save to nprofConfig.snapshotPath
start cpu profiling until POST /_profile/cpu/stop not executed
stop cpu profiling and save to nprofConfig.snapshotPath
take memory snapshot and save to nprofConfig.snapshotPath
scale GET-param can be number or string (kb, mb, gb)
get actual memory usage via process.memoryUsage
exec global.gc() if process started with --expose-gc
option
return before and after process.memoryUsage
return memory usage and event loop delay
you can add your own status metrics via config.statusFn hook function
see examples/status for more information
MIT