diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2019-05-02 16:10:10 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-05-05 20:19:17 +0300 |
commit | 7cfcf8069bb91240d25f83fa5ab5b7af2da49260 (patch) | |
tree | d5865e24bbf1f22408f86b0dc50699302cbcd21d /src/inspector_profiler.cc | |
parent | 0171bab46d6f57cf6b1ba89d4a79a022139937d1 (diff) |
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/inspector_profiler.cc')
-rw-r--r-- | src/inspector_profiler.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/inspector_profiler.cc b/src/inspector_profiler.cc index a3739d52b21..2d3f061e987 100644 --- a/src/inspector_profiler.cc +++ b/src/inspector_profiler.cc @@ -21,7 +21,6 @@ using v8::Object; using v8::String; using v8::Value; -using v8_inspector::StringBuffer; using v8_inspector::StringView; #ifdef _WIN32 @@ -254,6 +253,10 @@ MaybeLocal<Object> V8CpuProfilerConnection::GetProfile(Local<Object> result) { void V8CpuProfilerConnection::Start() { DispatchMessage("Profiler.enable"); DispatchMessage("Profiler.start"); + std::string params = R"({ "interval": )"; + params += std::to_string(env()->cpu_prof_interval()); + params += " }"; + DispatchMessage("Profiler.setSamplingInterval", params.c_str()); } void V8CpuProfilerConnection::End() { @@ -304,6 +307,7 @@ void StartProfilers(Environment* env) { } if (env->options()->cpu_prof) { const std::string& dir = env->options()->cpu_prof_dir; + env->set_cpu_prof_interval(env->options()->cpu_prof_interval); env->set_cpu_prof_dir(dir.empty() ? GetCwd() : dir); if (env->options()->cpu_prof_name.empty()) { DiagnosticFilename filename(env, "CPU", "cpuprofile"); |