自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
系統效能工具
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本頁面說明可用來評估成效指標的工具。
啟動時間
如要剖析開機時間,請參閱 Simpleperf 說明文件。config.yaml
檔案,加入您要搜尋的事件。config.yaml
應如下所示:
stop_event: <logcat log message which will terminate log collection after reboot>
events:
event1_name: <pattern that matches log message>
event2_
...
在某些裝置上,啟動時鐘時,可能會在前幾秒顯示錯誤的時間。雖然 bootanalyze 工具可支援即時修正時間,但您也可以在 config.yaml
中提供選用的時間修正模式。「最佳化開機時間」一文說明如何使用 Bootloader、裝置核心、I/O 調整、開機動畫和 SELinux 政策等元件,改善開機時間。
應用程式啟動時間
使用者希望應用程式能快速載入並快速回應。「應用程式啟動時間」一文詳細說明啟動程序的內部運作流程,並討論如何分析及改善啟動效能。
使用者介面
使用者介面 (UI) 效能測試可確保應用程式符合功能需求,並確保使用者與應用程式的互動順暢,以每秒 60 個影格的一致速度執行 (請參閱「Android 效能模式:為什麼要使用 60fps?」),且不會掉格或延遲影格。
詳情請參閱「測試 UI 效能」和「JankTest」。
記憶體
您可以透過下列兩種方式檢查應用程式的記憶體用量:
- 使用
procstats
的歷來用法演變。
- 使用
meminfo
建立時間快照。
如需詳細資訊,請參閱:
中央處理器
您可以使用下列工具查詢 CPU。
- 如要剖析 Android 應用程式和在 Android 上執行的原生程序,請參閱 Simpleperf 說明文件。
這是 Android 專用的原生中央處理器 (CPU) 剖析工具。Simpleperf 可在 Android 上剖析 Java 和 C++ 程式碼。Simpleperf 可執行檔可在 L 之後的 Android 版本上執行,而 Python 指令碼可在 N 之後的 Android 版本上使用。
Simpleperf 說明文件。
詳情請參閱 Simpleperf 說明文件。- 如要在與應用程式互動的過程中,即時檢查應用程式的 CPU 使用情形和執行緒活動,請使用 CPU 分析器。這樣做可以帶來許多好處,譬如能讓使用者有更快、更順暢的使用體驗,對裝置的電池續航力也有幫助。此外,您也可以檢查已記錄方法、函式和系統追蹤記錄的詳細資料。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","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 (世界標準時間)。"],[],[],null,["# System performance tools\n\nThis page describes the tools you can use to measure performance metrics.\n\nBoot time\n---------\n\nTo profile boot timing, use the\n[Simpleperf](https://android.googlesource.com/platform/system/extras/+/android16-release/simpleperf/doc/README.md)\ndocumentation.\n`config.yaml` file to include events you want to search for. `config.yaml`\nshould appear as follows: \n\n```scdoc\n stop_event: \u003clogcat log message which will terminate log collection after reboot\u003e\n events:\n event1_name: \u003cpattern that matches log message\u003e\n event2_\n ...\n```\n\nOn some devices, booting the clock may display an incorrect time for the first few seconds. While\nthe bootanalyze tool can accommodate a time correction out-of-the-box, you can provide an optional\ntime correction pattern in `config.yaml`.\n[Optimizing boot times](/devices/tech/perf/boot-times) explains how to improve boot\ntime using components such as Bootloader, Device Kernel, I/O tuning, Boot animation, and the\nSELinux policy.\n\nApp start-up time\n-----------------\n\nUsers expect apps to be quick to load and responsive.\n[App Startup Time](https://developer.android.com/topic/performance/vitals/launch-time)\ndetails the internals of the launch process and discusses how to profile and optimize startup\nperformance.\n\nUser interface\n--------------\n\nUser interface (UI) performance testing ensures that your app meets functional requirements and\nthat user interactions with your app are smooth, run at a consistent 60 frames per second (see\n[Android\nPerformance Patterns: Why 60fps?](https://www.youtube.com/watch?v=CaMTIgxCSqU&index=25&list=PLWz5rJ2EKKc9CBxr3BVjPTPoDPLdPIFCE)), and all without dropping or delaying frames.\n\nFor more information, see [Test\nUI Performance](https://developer.android.com/training/testing/performance) and\n[JankTest](https://developer.android.com/reference/android/support/test/jank/JankTest).\n\nMemory\n------\n\nYou can inspect app memory usage in one of two ways:\n\n- Over time, using `procstats`.\n- Snapshot in time, using `meminfo`.\n\nFor details, see:\n\n- To measure memory usage, see [View\n Memory Allocations](https://developer.android.com/studio/command-line/dumpsys.html#ViewingAllocations).\n- To use the Android Studio IDE to inspect memory, Android Studio provides a GUI-based memory usage tool. For details, see [View the Java Heap and\n Memory Allocations with Memory Profiler](https://developer.android.com/studio/profile/memory-profiler).\n- To conduct performance instrumentation and tracing on the Linux, Android, and Chrome platform and in user-space apps, use open source [Perfetto](https://perfetto.dev/#/).\n\nCentral processing unit\n-----------------------\n\nYou can use the following tools to query the CPU.\n\n- To profile Android apps *and* native processes running on Android, use [Simpleperf](https://android.googlesource.com/platform/system/extras/+/android16-release/simpleperf/doc/README.md) documentation.\na native central processing unit (CPU) profiling tool for Android. Simpleperf can profile Java and C++ code on Android. The Simpleperf executable can run on Android releases later than L and Python scripts can be used on Android releases later than N. \n\n[Simpleperf](https://android.googlesource.com/platform/system/extras/+/android16-release/simpleperf/doc/README.md) documentation. For details, see the [Simpleperf](https://android.googlesource.com/platform/system/extras/+/android16-release/simpleperf/doc/README.md) documentation.\n- To inspect your app's CPU usage and thread activity in real time while interacting with your app, use the [CPU Profiler](https://developer.android.com/studio/profile/cpu-profiler). Doing so has many advantages, such as providing a faster and smoother user experience and preserving device battery life. In addition, you can inspect the details of recorded method, function, and system traces."]]