From 7cfcf8069bb91240d25f83fa5ab5b7af2da49260 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 2 May 2019 21:10:10 +0800 Subject: 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 Reviewed-By: Anna Henningsen Reviewed-By: Franziska Hinkelmann Reviewed-By: Rich Trott --- src/node_options.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/node_options.cc') 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* 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.", -- cgit v1.2.3