工具
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
您可能很难确定何处存在性能问题以及要开始优化哪些代码。可以使用工具帮助缩小问题范围。
布局检查器
使用布局检查器可检查布局并查看重组次数。
如果界面呈现效果不佳,通常是因为出现编码错误,导致界面过度重组。另一方面,某些编码错误可能会在界面需要重组时阻止其重组,这意味着界面更改将不会呈现在屏幕上。跟踪重组有助于发现这两类问题。
重组本身并不是坏事;不过,意外重组可能会造成问题。
如需了解详情,请参阅布局检查器重组次数文档。
组合跟踪
使用组合跟踪可在系统跟踪记录中跟踪可组合函数。在首次调查性能问题时,轨迹通常是最佳信息来源。它们让您能够就问题所在以及从何处着手拟定假设。
其他资源
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-30。
[null,null,["最后更新时间 (UTC):2025-07-30。"],[],[],null,["# Tooling\n\nIt can be hard to know where a performance issue lies and what code to start\noptimizing. Start by using tools to help narrow down where your issue is.\n\nLayout Inspector\n----------------\n\nUse the [Layout Inspector](/develop/ui/compose/tooling/debug#layout_inspector) to inspect your layout and see recomposition\ncounts.\n\nIf your UI has poor performance, this is often because of a coding error that\nforces your UI to be recomposed excessively. On the other hand, some coding\nerrors can prevent your UI from being recomposed when it needs to be, which\nmeans UI changes aren't showing up on the screen. Tracking recompositions can\nhelp find both of these kinds of problems.\n\nRecomposition in itself is not bad; however, unexpected recomposition can be an\nissue.\n\nFor more information, see the Layout Inspector [recomposition counts](/develop/ui/compose/tooling/debug#recomposition-counts)\ndocumentation.\n\nComposition tracing\n-------------------\n\nUse [composition tracing](/develop/ui/compose/tooling/tracing) to trace your composable functions in a system\ntrace. Traces are often the best source of information when first looking into a\nperformance issue. They allow you to form a hypothesis of what the issue is and\nwhere to start looking.\n\nAdditional Resources\n--------------------\n\n- **[App performance guide](/topic/performance/overview)**: Discover best practices, libraries, and tools to improve performance on Android.\n- **[Inspect Performance](/topic/performance/inspecting-overview):** Inspect app performance.\n- **[Benchmarking](/topic/performance/benchmarking/benchmarking-overview):** Benchmark app performance.\n- **[App startup](/topic/performance/appstartup/analysis-optimization):** Optimize app startup.\n- **[Baseline profiles](/baseline-profiles):** Understand baseline profiles."]]