Nodejs CPU 分析

kam*_*esh 5 linux profiling node.js

我需要调试我的nodejs 进程的100% cpu 使用率。我发现node --prof myapp.js非常有帮助。现在我有另一个应用程序将分叉子进程,我需要调试该子进程。这就是我分叉流程的方式。

require('child_process').fork("childfile.js", ["arg1","arg2], {silent: true});
Run Code Online (Sandbox Code Playgroud)

现在我的问题是,是否可以分析子进程,那么我如何传递“--prof”选项。

小智 2

require('child_process').fork("childfile.js", ["arg1","arg2], {silent: true,execArgv:["--prof"]});
Run Code Online (Sandbox Code Playgroud)