summaryrefslogtreecommitdiff
path: root/src/node_options.cc
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-05-02 21:10:10 +0800
committerRich Trott <rtrott@gmail.com>2019-05-05 10:19:17 -0700
commit7cfcf8069bb91240d25f83fa5ab5b7af2da49260 (patch)
treed5865e24bbf1f22408f86b0dc50699302cbcd21d /src/node_options.cc
parent0171bab46d6f57cf6b1ba89d4a79a022139937d1 (diff)
downloadandroid-node-v8-7cfcf8069bb91240d25f83fa5ab5b7af2da49260.tar.gz
android-node-v8-7cfcf8069bb91240d25f83fa5ab5b7af2da49260.tar.bz2
android-node-v8-7cfcf8069bb91240d25f83fa5ab5b7af2da49260.zip
inspector: implement --cpu-prof-interval
This patch implements --cpu-prof-interval to specify the sampling interval of the CPU profiler started by --cpu-prof from the command line. Also adjust the interval to 100 in test-cpu-prof.js to make the test less flaky - it would fail if the time taken to finish the workload is smaller than the sampling interval, which was more likely on powerful machines when the interval was 1000. PR-URL: https://github.com/nodejs/node/pull/27535 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/node_options.cc')
-rw-r--r--src/node_options.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/node_options.cc b/src/node_options.cc
index a6d7e41e8d..a36666c3e0 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -161,6 +161,11 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
if (!cpu_prof_dir.empty()) {
errors->push_back("--cpu-prof-dir must be used with --cpu-prof");
}
+ // We can't catch the case where the value passed is the default value,
+ // then the option just becomes a noop which is fine.
+ if (cpu_prof_interval != kDefaultCpuProfInterval) {
+ errors->push_back("--cpu-prof-interval must be used with --cpu-prof");
+ }
}
debug_options_.CheckOptions(errors);
@@ -356,6 +361,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
"specified file name of the V8 CPU profile generated with "
"--cpu-prof",
&EnvironmentOptions::cpu_prof_name);
+ AddOption("--cpu-prof-interval",
+ "specified sampling interval in microseconds for the V8 CPU "
+ "profile generated with --cpu-prof. (default: 1000)",
+ &EnvironmentOptions::cpu_prof_interval);
AddOption("--cpu-prof-dir",
"Directory where the V8 profiles generated by --cpu-prof will be "
"placed. Does not affect --prof.",