如何有效且轻松地衡量布局性能?

How to measure layout performance effectively and easily?

因此article Hierarchy Viewer is deprecated. Now you can use Layout Inspector for analyzing your layout. But Layout Inspector does not measure. You can look for alerts due to layout performance by using systrace but it does not show you how to view layout hierarchy tree and looking at layout, measure and draw time. In Hierarchy Viewer you could do that. But now you seem to code something with Window.OnFrameMetricsAvailableListener

我不想编写任何代码来衡量布局性能。这个article show us that we can use dmtracedump. But honestly I don't know how to do that for drawing such a tree view:

那么你能告诉我一种无需任何编码即可衡量布局层次结构性能的方法吗?也许解释一下如何为此调用 dmtracedump?

或者 dmtracedump 只是为了以人类可读的形式显示跟踪文件?那么如何创建跟踪文件?

最后我发现 Android Studio 3.2 预览版有一个改进的探查器,您可以在其中捕获整个方法堆栈。在那里你可以找到名为 measure()、layout() 和 draw() 的 View 方法。