[英]Bar widths don't make sense in react profiler
I was looking at react profiler which seems a really nice tool.我在看反应分析器,这似乎是一个非常好的工具。 Have a look at these two screens:
看看这两个屏幕:
and和
What confuses me is following.让我感到困惑的是以下。 Look at the width of the
div
from first screenshot on which the left top corner of the tooltip starts (which says in total that component took 17.7 ms to render), now look at width of the Row
on second screenshot (tooltip of which says in total that component took 12.9 ms to render).从工具提示的左上角开始的第一个屏幕截图中查看
div
的宽度(这表明该组件总共花费了 17.7 毫秒来渲染),现在查看第二个屏幕截图上Row
的宽度(其中的工具提示在该组件总共花费了 12.9 毫秒来渲染)。 Why is the width of Row
larger than the width of div
left to it?为什么
Row
的宽度大于div
左边的宽度? When div
in total took more time to render?什么时候
div
总共需要更多时间来渲染? According to the docs, should not it be other way around?根据文档,不应该是其他方式吗? Am I missing something?
我错过了什么吗?
Each bar in the flame graph needs to be wide enough to contain all of its children- even the ones that weren't even rendered in the current commit (the gray subtree starting with TextField
in your screenshot above).火焰图中的每个条都需要足够宽以包含它的所有子项——甚至是那些甚至没有在当前提交中呈现的子项(上面屏幕截图中以
TextField
开头的灰色子树)。 that's why Row
is wider than div
.这就是为什么
Row
比div
更宽。 The width of each node gives you some idea of what the overall cost of that subtree would be if it were all to be rendered.每个节点的宽度让您了解如果全部渲染该子树的总成本是多少。 In this case, and most cases, color is the more important bit of information .
在这种情况下,以及大多数情况下,颜色是更重要的信息。
This note in the React Profiler docs mentions the distinction between color and width: React Profiler 文档中的这个注释提到了颜色和宽度之间的区别:
The width of a bar indicates how long it took to render the component (and its children) when they last rendered .
条的宽度表示在组件(及其子组件)最后一次渲染时渲染它们所用的时间。 If the component did not re-render as part of this commit, the time represents a previous render.
如果组件没有作为此提交的一部分重新渲染,则时间表示先前的渲染。 The wider a component is, the longer it took to render.
组件越宽,渲染时间越长。
The color of a bar indicates how long the component (and its children) took to render in the selected commit.
条形图的颜色表示组件(及其子组件)在所选提交中呈现的时间。 Yellow components took more time, blue components took less time, and gray components did not render at all during this commit.
黄色组件花费更多时间,蓝色组件花费更少时间,而灰色组件在此提交期间根本没有渲染。
The key part of the note about is "when they last rendered".关于注释的关键部分是“它们上次渲染的时间”。
Hope this helps clear up the confusion.希望这有助于消除混乱。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.