系統剖析總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
您可以透過 Android GPU Inspector (AGI) 執行系統剖析,包括為 Android 應用程式提供多種追蹤選項和 GPU 效能測量結果。相較於 Android Studio 剖析工具,AGI 會將多項功能合併為單一工具,並提供更深入的 GPU 涵蓋範圍和分析。可用的系統剖析資料包括:
- 應用程式追蹤記錄資料,包括 ATrace 標記
- CPU 和程序排程資料
- GPU 效能資訊,例如計數器、活動和生命週期資料
- Vulkan API 呼叫的追蹤資料
- 記憶體用量統計資料
- 電池使用統計資料
系統分析器是一種 AGI 元件,可管理用於多個應用程式影格的使用者介面和檢測。它以 Perfetto 追蹤系統為基礎。如要瞭解用來剖析個別應用程式影格的 AGI 元件,請參閱「Frame 分析器」總覽。
開始使用
AGI 快速入門導覽課程說明如何設定 AGI、擷取系統設定檔,然後開啟產生的追蹤檔。下一節將詳細說明設定選項。
剖析選項
本節說明分析應用程式時可用的主要選項。
應用程式設定
「Application」設定會識別在系統分析期間要執行和追蹤的 Android 應用程式。選取要在系統剖析期間追蹤的 Android 應用程式並非必要建議,因為如果沒有這個應用程式,產生的追蹤檔就不會包含應用程式的 ATrace 標記和 GPU 活動。
追蹤選項
「追蹤選項」會指定要收集的剖析資料。「Configure」按鈕會顯示可用的資料來源。
為了盡可能降低分析系統對 Android 裝置效能的影響,如果您將追蹤記錄「Duration」設為一分鐘,建議您減少選取的資料來源。不過,如果是一分鐘以下的追蹤記錄,您可以選取所有影響最小的資料來源。
CPU 選項
「CPU」選項可讓您透過 ftrace 收集 CPU 和程序排程資料。這可讓您查看每個 CPU 核心上執行的程序和執行緒。您也可以啟用這些選項:
- 頻率和閒置狀態:收集 CPU 核心頻率和閒置狀態變更事件,以便檢查 CPU 如何根據負載擴充或縮減。
- 排程鏈結 / 延遲:收集有關執行緒排程延遲和先佔的其他執行緒狀態資料。
- 執行緒配量:在程序檢視畫面中收集 ATrace 標記。
GPU 選項
「GPU」選項可讓您剖析應用程式的 GPU 用量,例如 GPU 頻率和記憶體用量資料的集合。如要收集這項資料,您必須在「Application」設定中指定要追蹤的應用程式。可用的選項如下:
計數器:收集 GPU 計數器樣本。這項資料可用來判斷 GPU 的忙碌程度及找出瓶頸,因此建議您調整這些設定。
計數器會因硬體而異。例如,樣本收集的最低頻率 (輪詢率) 可能因計數器類型而異。如要瞭解支援的計數器,請參閱 GPU 效能計數器。
影格生命週期:追蹤 SufaceFlinger 事件,這有助於判斷影格緩衝區在應用程式、合成器和視窗管理員中的移動方式。這些事件可讓您找出遺失的應用程式影格,並找出轉譯管道中的延遲來源。
轉譯階段配量:收集相關資料,協助判斷應用程式如何使用 GPU。
Vulkan 選項
Vulkan 選項可讓您追蹤 Vulkan API 呼叫,然後透過函式類型啟用該呼叫。您可以使用這項資料來判斷 Vulkan API 呼叫的 CPU 負擔。追蹤記錄會記錄每個函式呼叫的時間長度,在您分析 Vulkan 事件追蹤中的資料時,會顯示在應用程式的執行緒配量中。
其他選項
其他系統剖析選項包括:
記憶體:收集全域和各個程序的必要記憶體用量統計資料。
電池:收集電池統計資料。這可讓您大致估算應用程式的耗電量。
在裝置上強制追蹤到檔案:追蹤資料通常在擷取追蹤記錄時透過 USB 串流,這樣可以減少負載量,並允許長時間追蹤。不過,如果您因為 USB 延遲時間而遇到問題或遺失剖析資料,可以選取這個選項,將追蹤檔儲存在裝置上,AGI 會在追蹤結束後下載。這需要在裝置內部儲存空間中有足夠的空間來儲存追蹤檔。
進階模式
「切換為進階模式」連結會啟動進階設定模式,可讓您手動編輯儲存剖析選項的 Pefetto 追蹤記錄設定。
查看及分析結果
如果您開啟的追蹤檔含有系統剖析資料,AGI 就會在系統分析器 UI 中顯示資料進行分析。如要瞭解如何查看資料,請參閱「查看系統設定檔」。
以下主題說明如何使用 AGI 分析系統剖析資料:
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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 profiling overview\n\nWith Android GPU Inspector (AGI), you can perform system profiling that includes\na wide range of tracing options and GPU performance measurements for your\nAndroid app. In comparison to the\n[Android Studio profiling tools](/topic/performance/tracing),\nAGI combines many of those capabilities into one tool, and then provides more\nin-depth GPU coverage and analysis. The available system profiling data\nincludes the following:\n\n- App trace data including [ATrace](https://perfetto.dev/docs/data-sources/atrace) markers\n- CPU and process scheduling data\n- GPU performance info such as counter, activity, and lifecycle data\n- Trace data for Vulkan API calls\n- Memory usage statistics\n- Battery usage statistics\n\nSystem Profiler is the AGI component that manages the UI and\ninstrumentation for system profiling over multiple app frames. It is built on\ntop of the [Perfetto](https://perfetto.dev) tracing system. For\ninformation about the AGI component for profiling individual app frames, see the\n[Frame profiler](/agi/frame-trace/frame-profiler) overview.\n\nGet started\n-----------\n\nThe AGI [quickstart](/agi/start) describes how to set up AGI, capture a system\nprofile, and then open the resulting trace file. The next section describes the\nconfiguration options in more detail.\n\nProfiling options\n-----------------\n\nThis sections describes the main options that are available when you\n[profile an app](/agi/start#system-profile).\n\n### Application settings\n\nThe **Application** settings identify the Android app to run and trace during\nsystem profiling. Selecting an Android app to trace during system profiling is\noptional but recommended because without it, the resulting trace file won't\ninclude [ATrace](https://perfetto.dev/docs/data-sources/atrace)\nmarkers and GPU activity for an application.\n\n### Trace options\n\nThe **Trace Options** specify the profiling data to collect. The\n**Configure** button displays the available data sources.\n\nTo minimize the performance impact on your Android device when you profile the\nsystem, we recommend that you select fewer data sources if you set the trace\n**Duration** to over a minute. However, for traces under a minute, you can\nselect all data sources with minimal impact.\n\n#### CPU options\n\nThe **CPU** option enables the collection of CPU and\nprocess scheduling data through\n[ftrace](https://en.wikipedia.org/wiki/Ftrace). This\nallows you to see what process and thread is running on each CPU\ncore. You can also enable these options:\n\n- **Frequency and idle states**: Collects CPU core frequency and idle state change events, which allows you to inspect how the CPU is scaled up or down based on load.\n- **Scheduling chains / latency**: Collects additional thread state data about thread scheduling delays and preemption.\n- **Thread slices**: Collects ATrace markers in the process views.\n\n#### GPU options\n\nThe **GPU** options enable profiling of your app's GPU usage, such as the\ncollection of GPU frequency and memory usage data. To collect this data, you\nmust specify an application to trace in the **Application** settings. The\noptions include the following:\n\n- **Counters**: Collects GPU counter samples. This data is used to determine\n how busy the GPU is and locate bottlenecks, so we recommend that you configure\n these settings.\n\n The counters are hardware-specific. For example, the minimum frequency for\n sample collection (**Poll Rate** ) may differ based on the counter type. For\n information about supported counters, see\n [GPU performance counters](/agi/sys-trace/counters-arm).\n- **Frame Lifecycle** : Traces\n [SufaceFlinger](https://source.android.com/devices/graphics/surfaceflinger-windowmanager)\n events, which help determine how frame buffers move through your application,\n the compositor, and window manager. These events allow you to locate missed\n app frames and identify sources of latency in your rendering pipeline.\n\n- **Renderstage slices** Collects data that helps determine how your application\n is using the GPU.\n\n#### Vulkan options\n\nThe **Vulkan** options enable tracing of Vulkan API calls, which can then be\nenabled by function type. You can use this\ndata to determine the CPU overhead of Vulkan API calls. The trace records the\nduration of each function call, which is displayed within your app's thread\nslices when you analyze the data in the\n[Vulkan event track](/agi/sys-trace/system-profiler-gui#vulkan_event_track).\n\n#### Other options\n\nThe additional system profiling options include:\n\n- **Memory**: Collect essential memory usage statistics, both globally and for\n each process.\n\n- **Battery**: Collects battery statistics. This can give you a rough estimate\n of the power usage of your application.\n\n- **Force Tracing into a File on the Device**: Trace data is typically streamed\n over USB while the trace is being captured, which has the least amount of\n overhead and allows for long traces. However, if you encounter problems\n or dropped profiling data due to USB latency, you can select this option to\n save the trace file on the device, which AGI then downloads after tracing\n concludes. This requires sufficient space on your device's internal storage\n to store the trace file.\n\n#### Advanced mode\n\nThe **Switch to advanced mode** link launches advanced configuration mode, which\nallows you to manually edit the\n[Pefetto trace configuration](https://perfetto.dev/docs/concepts/config)\nthat stores your profiling options.\n\nView and analyze the results\n----------------------------\n\nWhen you open a trace file that contains system profiling data, AGI displays the\ndata in the System Profiler UI for analysis. For information\nabout viewing the data, see [View a system profile](/agi/sys-trace/system-profiler-gui).\n\nThese topics describe how to analyze system profiling data with AGI:\n\n- [Analyze frame processing times](/agi/sys-trace/long)\n- [Analyze memory efficiency](/agi/sys-trace/memory-efficiency)\n- [Analyze texture memory bandwidth usage](/agi/sys-trace/texture-memory-bw)\n- [Analyze vertex memory bandwidth usage](/agi/sys-trace/vertex-memory-bw)\n- [Analyze thread scheduling](/agi/sys-trace/threads-scheduling)"]]