Javascript Chrome 调试器的分析器中的“(程序)”是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3847954/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 06:22:25  来源:igfitidea点击:

What is “(program)” in Chrome debugger’s profiler?

javascriptgoogle-chrome-devtools

提问by hvgotcodes

What is “(program)” in the function column of the Chrome debugger?

Chrome调试器的功能栏中的“(程序)”是什么?

采纳答案by Nick Craver

(program)is Chrome itself, the root of the tree calling all other code...it's there because the jump from native code to JavaScript, resource loading, etc. has to start somewhere:)

(program)是 Chrome 本身,是调用所有其他代码的树的根...它在那里是因为从本机代码跳转到 JavaScript、资源加载等必须从某个地方开始:)

You can see examples of the treeview in the Chrome developer tool docs.

您可以在 Chrome 开发人员工具文档 中查看树视图的示例。

回答by user1009908

I believe (program) is native code, not the root of the tree.

我相信(程序)是本机代码,而不是树的根。

See this thread:

看到这个线程:

https://bugs.webkit.org/show_bug.cgi?id=88446

https://bugs.webkit.org/show_bug.cgi?id=88446

So, more like system calls than like main().

所以,更像是系统调用而不是 main()。

Apparently it includes idle time. Also, some profiling of (program) is available from chrome://profiler/

显然它包括空闲时间。此外,可以从 chrome://profiler/ 获得(程序)的一些分析

回答by Mike Dunlavey

As @Nick says, it has to start somewhere.

正如@Nick 所说,它必须从某个地方开始。

It looks like the CPU Profiler part is like so many other profilers that are based on the same concepts as gprof.

看起来 CPU Profiler 部分就像许多其他基于与 gprof 相同概念的分析器一样

For example, selfis nearly a useless number unless there is something like a bubble-sort of a big array of numbers in some code that you can edit. Highly unlikely.

例如,self几乎是一个无用的数字,除非在一些您可以编辑的代码中存在诸如对大量数字进行冒泡排序之类的东西。不大可能。

Totalshould include callees, so that's more useful. However, unless samples are taken during blocked time as well as during running time, it is still pretty useless except for totally cpu-bound programs.

Total应该包括被调用者,这样更有用。然而,除非在阻塞时间和运行时间采集样本,否则除了完全受 CPU 限制的程序外,它仍然毫无用处。

It gives you these stats by function, rather than by line of code. That means (if you could rely on Totalpercent) that a function costs that much, in the sense that if you could somehow make it take zero time, such as by stubbing it, that percent is how much time you would save.

它按功能而不是按代码行为您提供这些统计信息。这意味着(如果您可以依靠百分比)一个函数的成本如此之高,从某种意义上说,如果您可以以某种方式使其花费零时间,例如通过存根,那么该百分比就是您将节省多少时间。

So if you want to focus on a costly function, you need to hunt inside it for what could be optimized. In order to do that, you need to know how the time is subdivided among the lines of code in the function. If you had cost on a line of code basis, it would take you directly to those lines.

因此,如果您想专注于一个代价高昂的功能,您需要在其中寻找可以优化的内容。为了做到这一点,您需要知道时间在函数中的代码行之间是如何细分的。如果您有一行代码的成本,它会直接带您到那些行。

I don't know if you will be able to get a better profiler, like a wall-clock stack sampler reporting at the line level, such as Zoom. Here's how I do it.

我不知道您是否能够获得更好的分析器,例如在行级别报告的挂钟堆栈采样器,例如Zoom。这是我如何做到的