diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2019-03-23 07:39:52 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2019-04-19 15:38:23 +0800 |
commit | e0e308448240260c207958dfc3dd9245d903af85 (patch) | |
tree | 611f54d2aac113f735f7a3047f2857561192e969 /src/node_options.cc | |
parent | 57ab3b56fcba725e1af4ed7f8a05bbdbd0b8a4d9 (diff) | |
download | android-node-v8-e0e308448240260c207958dfc3dd9245d903af85.tar.gz android-node-v8-e0e308448240260c207958dfc3dd9245d903af85.tar.bz2 android-node-v8-e0e308448240260c207958dfc3dd9245d903af85.zip |
inspector: implement --cpu-prof[-path]
This patch introduces a CLI flag --cpu-prof that starts the V8
CPU profiler on start up, and ends the profiler then writes the
CPU profile before the Node.js instance (on the main thread or
the worker thread) exits. By default the profile is written to
`${cwd}/CPU.${yyyymmdd}.${hhmmss}.${pid}.${tid}.${seq}.cpuprofile`.
The patch also introduces a --cpu-prof-path flag for the user
to specify the path the profile will be written to.
Refs: https://github.com/nodejs/node/issues/26878
PR-URL: https://github.com/nodejs/node/pull/27147
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/node_options.cc')
-rw-r--r-- | src/node_options.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/node_options.cc b/src/node_options.cc index d9c0d472fb..db92a0c2fd 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -332,6 +332,18 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { &EnvironmentOptions::prof_process); // Options after --prof-process are passed through to the prof processor. AddAlias("--prof-process", { "--prof-process", "--" }); +#if HAVE_INSPECTOR + AddOption("--cpu-prof", + "Start the V8 CPU profiler on start up, and write the CPU profile " + "to disk before exit. If --cpu-prof-path is not specified, write " + "the profile to the current working directory.", + &EnvironmentOptions::cpu_prof); + AddOption("--cpu-prof-path", + "Path the V8 CPU profile generated with --cpu-prof will be " + "written to.", + &EnvironmentOptions::cpu_prof_path); + Implies("--cpu-prof-path", "--cpu-prof"); +#endif // HAVE_INSPECTOR AddOption("--redirect-warnings", "write warnings to file instead of stderr", &EnvironmentOptions::redirect_warnings, |