官方网址 Easy profiling for Node.js Applications | Node.js
profiling是Node.js内置使用V8中的分析器,它在程序执行期间定期对堆栈进行采样。它记录这些样本的结果,以及重要的优化事件,如jit编译,作为一系列标记:
1.启动时增加--node-args="--prof"
pm2 restart all --node-args="--prof"
或
node --prof
2.ls -al找到指定进程的log
3.选择指定的log生成可读文件
node --prof-process isolate-0x2247360-v8-10944.log > process.txt
4.查看文件
less process.txt
清理日志
rm isolate-0x*.log