Công cụ
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Thật khó để biết vấn đề về hiệu suất nằm ở đâu và mã nào để bắt đầu tối ưu hoá. Hãy bắt đầu bằng cách sử dụng các công cụ giúp thu hẹp vấn đề bạn gặp phải.
Layout Inspector
Sử dụng Layout Inspector để kiểm tra bố cục và xem số lần kết hợp lại.
Nếu giao diện người dùng có hiệu suất kém, thì điều này thường là do lỗi lập trình buộc giao diện người dùng phải kết hợp lại quá mức. Mặt khác, một số lỗi lập trình có thể ngăn việc kết hợp lại giao diện người dùng khi cần, tức là các thay đổi về giao diện người dùng không hiện trên màn hình. Khi theo dõi số lần kết hợp lại, bạn có thể phát hiện cả hai vấn đề này.
Bản thân việc kết hợp lại không phải là điều xấu; tuy nhiên việc kết hợp lại ngoài dự kiến có thể là vấn đề.
Để biết thêm thông tin, hãy xem tài liệu về số lần kết hợp lại của Layout Inspector.
Theo dấu đối tượng kết hợp
Sử dụng tính năng theo dõi thành phần kết hợp để theo dõi các hàm có khả năng kết hợp trong dấu vết hệ thống. Thông thường, dấu vết là nguồn thông tin hữu ích nhất trong bước đầu xem xét vấn đề về hiệu suất. Thông qua các dấu vết, bạn có thể xây dựng giả thuyết xem vấn đề đó là gì và nên bắt đầu xem xét ở đâu.
Tài nguyên khác
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-30 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-30 UTC."],[],[],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."]]