เครื่องมือ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
การระบุว่าปัญหาด้านประสิทธิภาพอยู่ที่ใดและควรเริ่มเพิ่มประสิทธิภาพโค้ดใดอาจเป็นเรื่องยาก เริ่มต้นด้วยการใช้เครื่องมือเพื่อช่วยจำกัดขอบเขตของปัญหา
เครื่องมือตรวจสอบเลย์เอาต์
ใช้เครื่องมือตรวจสอบเลย์เอาต์เพื่อตรวจสอบเลย์เอาต์และดูจำนวนการจัดองค์ประกอบใหม่
หาก UI มีประสิทธิภาพไม่ดี มักเกิดจากข้อผิดพลาดในการเขียนโค้ดที่
บังคับให้ UI ของคุณได้รับการจัดองค์ประกอบใหม่มากเกินไป ในทางกลับกัน ข้อผิดพลาดในการเขียนโค้ดบางอย่างอาจทำให้ UI ไม่ได้รับการจัดองค์ประกอบใหม่เมื่อจำเป็น ซึ่งหมายความว่าการเปลี่ยนแปลง UI จะไม่แสดงบนหน้าจอ การติดตามการเปลี่ยนองค์ประกอบจะช่วยค้นหาปัญหาทั้ง 2 ประเภทนี้
การประกอบใหม่ไม่ใช่สิ่งที่ไม่ดี แต่การประกอบใหม่ที่ไม่คาดคิดอาจเป็นปัญหาได้
ดูข้อมูลเพิ่มเติมได้ที่เอกสารประกอบเกี่ยวกับจำนวนการจัดองค์ประกอบใหม่ของ Layout Inspector
การติดตามการเรียบเรียง
ใช้การติดตามการประกอบเพื่อติดตามฟังก์ชันที่ประกอบได้ใน System Trace โดยทั่วไปแล้ว Trace เป็นแหล่งข้อมูลที่ดีที่สุดเมื่อตรวจสอบปัญหาด้านประสิทธิภาพเป็นครั้งแรก
ซึ่งจะช่วยให้คุณตั้งสมมติฐานเกี่ยวกับปัญหาและ
จุดเริ่มต้นในการค้นหาได้
แหล่งข้อมูลเพิ่มเติม
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-30 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 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."]]