简体   繁体   English

有没有办法在javascript中检测Chrome / Chromium / V8探查器是否正在运行?

[英]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. 我可以运行应用程序的prod构建,但然后我会丢失有用的函数名称。

My hope is that there is some sort of mechanism like checking if NODE_ENV is 'production'. 我希望有一种机制,比如检查NODE_ENV是否为“生产”。

V8 developer here. V8开发人员在这里。 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). 您可以进行“开发”构建(完整符号和调试功能),“分析”模式(仅符号)和“生产”构建(无符号,无调试功能)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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