ตรวจสอบประสิทธิภาพ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ตรวจสอบประสิทธิภาพเพื่อช่วยให้คุณเข้าใจสิ่งที่เกิดขึ้นในแอปและ
ตรวจสอบว่าแอปเป็นไปตามที่คุณคาดหวัง
Android มีเครื่องมือหลายอย่างที่คุณใช้ตรวจสอบประสิทธิภาพของแอปได้
เมื่อเริ่มต้นใช้งาน เราขอแนะนำให้คุณมุ่งเน้นที่พื้นที่เดียวในแต่ละครั้งระหว่างการตรวจสอบ
ซึ่งอาจรวมถึงส่วนต่อไปนี้
- การเริ่มต้นแอป
- การแสดงผลช้า (กระตุก)
- เหตุการณ์การเปลี่ยนหน้าจอและการนำทาง
- งานที่ใช้เวลานาน
- การดำเนินการในเบื้องหลัง เช่น I/O และการเชื่อมต่อเครือข่าย
หรือจะตรวจสอบเส้นทางการใช้งานที่สำคัญของผู้ใช้ในเวิร์กโฟลว์ของแอปก็ได้
ซึ่งจะช่วยให้คุณเข้าใจภาพรวมของจุดที่ประสิทธิภาพและความคาดหวังไม่สอดคล้องกัน
เมื่อตรวจสอบประสิทธิภาพ จะมีแนวทางหลักๆ 2 แนวทาง ได้แก่ แนวทางแบบกำหนดเองและแนวทางอัตโนมัติ
คุณน่าจะเริ่มต้นด้วยการแก้ไขข้อบกพร่องด้วยตนเองเมื่อตรวจสอบพื้นที่ใหม่
การตรวจสอบด้วยตนเอง
หลังจากตัดสินใจเลือกส่วนของแอปที่จะตรวจสอบแล้ว คุณสามารถใช้เครื่องมือต่างๆ
เพื่อระบุสิ่งที่เกิดขึ้นได้อย่างแม่นยำ
เครื่องมือที่ครอบคลุมที่สุดในการตรวจสอบประสิทธิภาพในอุปกรณ์ที่ใช้ Android 9 ขึ้นไปคือ Perfetto Perfetto ให้รายละเอียดข้อมูลการติดตาม
ที่ละเอียดที่สุดเท่าที่จะเป็นไปได้ การใช้ตัวกรองที่มีประสิทธิภาพจะช่วยให้คุณปรับ
ระดับรายละเอียดได้ตามต้องการ ดูข้อมูลเพิ่มเติมเกี่ยวกับวิธีบันทึกการติดตาม
จากอุปกรณ์ Android ได้ในคู่มือการเริ่มต้นอย่างรวดเร็ว: บันทึกการติดตามใน
Android
โปรไฟล์เลอร์ Android ที่สร้างขึ้นใน Android Studio ยังให้ข้อมูลเชิงลึกที่มีประโยชน์เกี่ยวกับประสิทธิภาพของแอปได้ด้วย ซึ่งคุณสามารถจำกัดระดับรายละเอียดไว้ที่แอปของคุณ หรือเมื่อเรียกใช้ในอุปกรณ์ที่เก่ากว่า Android 9
ดูข้อมูลเพิ่มเติมได้ที่ภาพรวมของการติดตามระบบ หรือดูซีรีส์แบบเจาะลึกเกี่ยวกับการแก้ไขข้อบกพร่องด้านประสิทธิภาพ
การทดสอบอัตโนมัติ
นอกจากการตรวจสอบด้วยตนเองแล้ว คุณยังตั้งค่าการทดสอบอัตโนมัติเพื่อรวบรวมและ
รวบรวมข้อมูลประสิทธิภาพได้ด้วย ซึ่งจะช่วยให้คุณเข้าใจสิ่งที่ผู้ใช้เห็นจริงและระบุได้ว่าเมื่อใดที่อาจเกิดการถดถอย ดูข้อมูลเพิ่มเติมเกี่ยวกับการตั้งค่าการทดสอบประสิทธิภาพอัตโนมัติสำหรับแอปได้ที่เปรียบเทียบแอป
คุณใช้เครื่องมือต่างๆ เพื่อตรวจสอบและติดตามประสิทธิภาพเพื่อช่วย
ปรับปรุงแอปได้
ทําความเข้าใจประสิทธิภาพในพื้นที่ด้วยคลังข้อมูลเปรียบเทียบ
ทำความเข้าใจประสิทธิภาพในเวอร์ชันที่ใช้งานจริง
- Android Vitals ช่วยปรับปรุงประสิทธิภาพของแอปได้โดยการแจ้งเตือนคุณ
เมื่อเมตริกประสิทธิภาพต่างๆ เกินเกณฑ์ที่กำหนดไว้ล่วงหน้า
- SDK ประสิทธิภาพของ Firebase จะรวบรวมเมตริกต่างๆ เกี่ยวกับประสิทธิภาพของแอป เช่น คุณสามารถใช้ SDK เพื่อวัดเวลาระหว่าง
เมื่อผู้ใช้เปิดแอปและเมื่อแอปตอบสนอง ซึ่งจะช่วย
ระบุคอขวดที่อาจเกิดขึ้นในการเริ่มต้น
สร้างโปรไฟล์ในเครื่องด้วย Android Studio
เครื่องมือการทำโปรไฟล์ขั้นสูง: การติดตาม Perfetto
แหล่งข้อมูลเพิ่มเติม
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 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-27 UTC"],[],[],null,["# Inspect performance to help you understand what is happening in your app and\nensure it meets your expectations.\n\nAndroid provides several tools you can use to inspect your app's performance.\nWhen getting started, we recommend you focus on one area at a time during\ninspection. These areas can include the following:\n\n- App startup\n- Slow rendering (jank)\n- Screen transitions and navigation events\n- Long running work\n- Operations in the background, such as I/O and networking\n\nAlternatively, you can inspect critical user journeys of your app's workflow.\nThis can help you gain a holistic understanding of where performance and\nexpectations don't align.\n\nThere are two main approaches when inspecting performance, manual and automated.\nIt's likely that you start with manual debugging when inspecting a new area.\n\nManual inspection\n-----------------\n\nAfter deciding which area of your app to inspect, you can use a variety of tools\nto identify what exactly is happening.\n\nThe most comprehensive tool to inspect performance on devices running Android 9\nand higher is [Perfetto](https://perfetto.dev/). Perfetto provides the highest possible\ndetail of tracing information. By using powerful filters, you can adjust the\nlevel of detail for your needs. For more information about how to capture traces\nfrom Android devices, see the [Quickstart: Record traces on\nAndroid](https://perfetto.dev/docs/quickstart/android-tracing) guide.\n\nThe [Android profilers](/studio/profile) built into Android Studio can also provide valuable\ninsights into your app's performance, where you can limit the level of detail to\nyour app, or when running on devices earlier than Android\n9.\n\nFor more information, see [Overview of system tracing](/topic/performance/tracing) or watch the in-depth\nseries on [performance debugging](https://www.youtube.com/playlist?list=PLWz5rJ2EKKc-xjSI-rWn9SViXivBhQUnp).\n\nAutomated testing\n-----------------\n\nIn addition to manual inspection, you can set up automated tests to collect and\naggregate performance data. This helps you understand what users are actually\nseeing and identify when regressions might occur. For more information about\nsetting up automated performance tests for your app, see [Benchmark your\napp](/topic/performance/benchmarking/benchmarking-overview).\n\nApp startup performance\n-----------------------\n\nThere are multiple tools you can use to inspect and monitor performance to help\nimprove your app.\n\n### Understand performance locally with Benchmark libraries\n\n- The [Macrobenchmark library](/topic/performance/benchmarking/macrobenchmark-overview) helps you measure larger end-user interactions, such as startup, interacting with the UI, and animations.\n- The [Microbenchmark library](/topic/performance/benchmarking/microbenchmark-overview) helps analyze performance of more granular, app-specific situations.\n\n### Understand performance in production\n\n- [Android vitals](/topic/performance/vitals) can help improve your app's performance by alerting you when various performance metrics exceed predetermined thresholds.\n- The [Firebase performance SDK](https://firebase.google.com/docs/perf-mon/get-started-android) collects various metrics about your app's performance. For example, you can use the SDK to measure the time between when the user opens the app and when the app becomes responsive, helping identify potential startup bottlenecks.\n\n### Profile locally with Android Studio\n\n- Use [Android Studio](/studio/profile) to record and view system traces or stack sampling traces.\n- [Record traces](/studio/profile/record-traces) using Android Studio. For additional information, see the [Performance Debugging video series](https://www.youtube.com/playlist?list=PLWz5rJ2EKKc-xjSI-rWn9SViXivBhQUnp).\n- Use [Simpleperf](https://android.googlesource.com/platform/system/extras/+/master/simpleperf/doc/README.md), a native stack sampling tool for Android, to profile both Android apps and native processes running on Android. It can profile both Java and C++ code on Android.\n\n### Advanced profiling tools: Perfetto tracing\n\n- [Perfetto](https://perfetto.dev/): a platform-wide tracing tool available on Android 10 (API level 29) and higher. For more information, see the [overview of Perfetto traces](https://perfetto.dev/docs/).\n- [Run Perfetto using `adb`](/studio/command-line/perfetto): describes how to run the `perfetto` command-line tool to capture traces.\n- [Recording a trace through the cmdline](https://perfetto.dev/docs/quickstart/android-tracing#recording-a-trace-through-the-cmdline): describes how to build and run the `perfetto` command-line tool to capture traces.\n- [Perfetto web-based trace viewer](https://perfetto.dev/docs/quickstart/android-tracing#recording-a-trace-through-the-perfetto-ui): opens Perfetto traces and displays a complete report. You can also open [Systrace](/topic/performance/tracing) traces in this viewer using the legacy UI option.\n\nAdditional resources\n--------------------\n\n- [Performance debugging - MAD skills series](https://www.youtube.com/playlist?list=PLWz5rJ2EKKc-xjSI-rWn9SViXivBhQUnp)\n- [Profile your app performance](/studio/profile)\n- [Write a Macrobenchmark](/topic/performance/benchmarking/macrobenchmark-overview)\n- [Microbenchmark](/topic/performance/benchmarking/microbenchmark-overview)"]]