简体   繁体   中英

Is there a way to detect in javascript if the Chrome/Chromium/V8 profiler is running?

My application has several costly debugging/development features that I would like to disable while the profiler is running.

I could run a prod build of the application but then I would lose useful function names.

My hope is that there is some sort of mechanism like checking if NODE_ENV is 'production'.

V8 developer here. I don't believe it is possible to detect whether the profiler is running. I think that's probably a good state of affairs -- it would potentially be very confusing if applications changed their behavior when you profile them. Even in your case where you're doing that intentionally (so you wouldn't be surprised), I guess it could easily lead to weird artifacts.

I think that different build modes are probably the best solution. You could have a "development" build (full symbols and debugging features), a "profiling" mode (symbols only), and a "production" build (no symbols, no debugging features).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM