summaryrefslogtreecommitdiff
path: root/src/env-inl.h
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-03-23 07:39:52 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2019-04-19 15:38:23 +0800
commite0e308448240260c207958dfc3dd9245d903af85 (patch)
tree611f54d2aac113f735f7a3047f2857561192e969 /src/env-inl.h
parent57ab3b56fcba725e1af4ed7f8a05bbdbd0b8a4d9 (diff)
downloadandroid-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/env-inl.h')
-rw-r--r--src/env-inl.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/env-inl.h b/src/env-inl.h
index e8943ffaf5..3a6caa19f8 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -659,6 +659,25 @@ inline profiler::V8CoverageConnection* Environment::coverage_connection() {
inline const std::string& Environment::coverage_directory() const {
return coverage_directory_;
}
+
+inline void Environment::set_cpu_profiler_connection(
+ std::unique_ptr<profiler::V8CpuProfilerConnection> connection) {
+ CHECK_NULL(cpu_profiler_connection_);
+ std::swap(cpu_profiler_connection_, connection);
+}
+
+inline profiler::V8CpuProfilerConnection*
+Environment::cpu_profiler_connection() {
+ return cpu_profiler_connection_.get();
+}
+
+inline void Environment::set_cpu_profile_path(const std::string& path) {
+ cpu_profile_path_ = path;
+}
+
+inline const std::string& Environment::cpu_profile_path() const {
+ return cpu_profile_path_;
+}
#endif // HAVE_INSPECTOR
inline std::shared_ptr<HostPort> Environment::inspector_host_port() {