--cpu-prof
在启动时启动 V8 CPU 分析器,并在退出前将 CPU 分析结果写入磁盘。
【Starts the V8 CPU profiler on start up, and writes the CPU profile to disk before exit.】
如果未指定 --cpu-prof-dir,生成的性能分析文件将放在当前工作目录中。
【If --cpu-prof-dir is not specified, the generated profile is placed
in the current working directory.】
如果未指定 --cpu-prof-name,生成的配置文件将命名为 CPU.${yyyymmdd}.${hhmmss}.${pid}.${tid}.${seq}.cpuprofile。
【If --cpu-prof-name is not specified, the generated profile is
named CPU.${yyyymmdd}.${hhmmss}.${pid}.${tid}.${seq}.cpuprofile.】
$ node --cpu-prof index.js
$ ls *.cpuprofile
CPU.20190409.202950.15293.0.0.cpuprofile 如果指定了 --cpu-prof-name,提供的值将用作文件名的模板。支持以下占位符,并将在运行时进行替换:
【If --cpu-prof-name is specified, the provided value is used as a template
for the file name. The following placeholder is supported and will be
substituted at runtime:】
${pid}— 当前进程 ID
$ node --cpu-prof --cpu-prof-name 'CPU.${pid}.cpuprofile' index.js
$ ls *.cpuprofile
CPU.15293.cpuprofile