「由上往下」和「由下往」的圖表
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
「Top Down」分頁會列出呼叫,該清單可展開方法或函式節點以顯示受呼叫端。圖 2 顯示下列呼叫圖的「Top Down」圖。圖表中的每個箭頭分別指向呼叫端和受呼叫端。
圖 1. 呼叫圖範例說明了方法 D 的自身時間、子項時間和總時間。
如圖 2 所示,在「Top Down」分頁中展開方法 A 的節點,即可顯示其受呼叫端、方法 B 和 D。之後,延伸方法 D 的節點會公開其受呼叫端,例如方法 B 和 C。類似於「Flame Chart」分頁,「Top Down」樹狀結構會聚集共用相同呼叫堆疊的相同方法的追蹤記錄資訊。也就是說,「Flame Chart」分頁以圖形的方式呈現「Top Down」分頁。
「Top Down」分頁提供以下資訊,以說明每個呼叫所消耗的 CPU 作業時間 (時間也會以執行緒在所選範圍內的總時間百分比表示):
- 「Self」:方法或函式呼叫執行專屬程式碼的時間,而非受呼叫端的時間,如圖 1 中方法 D 所示。
- 「Children」:方法或函式呼叫執行受呼叫端的時間,而非其自身程式碼的時間,如圖 1 中方法 D 所示。
- 「Total」:該方法「Self」和「Children」的時間總和。這代表應用程式執行呼叫的總時間,如圖 1 中方法 D 所示。
圖 2. 「Top Down」樹狀圖。
圖 3. 圖 5 中方法 C 的「Bottom Up」樹狀圖。
「Bottom Up」分頁會顯示呼叫清單,展開其中的函式或方法節點後,即可顯示相應呼叫端。使用圖 2 中顯示的追蹤記錄範例,圖 3 提供了方法 C 的「Bottom Up」樹狀圖。在「Bottom Up」樹狀圖中開啟方法 C 的節點,會顯示各自不重複的呼叫端,亦即方法 B 和 D。請注意,雖然 B 呼叫了 C 兩次,但 B 在「Bottom Up」樹狀圖中展開方法 C 的節點時只會出現一次。之後,展開 B 節點即可顯示呼叫端 A 和方法 D。
「Bottom Up」分頁可用來依照耗費最多(或最少)CPU 作業時間將方法或函式排序。您可以查看每個節點,以判斷哪些呼叫端花費最多的 CPU 作業時間叫用這些方法或函式。相較於「Top Down」樹狀結構,「Bottom Up」樹狀結構每種方法或函式的時間資訊指的是每個樹狀結構頂端的方法 (頂端節點)。CPU 作業時間也代表記錄在錄音期間的總使用時間百分比。下表說明如何解讀熱門節點及其呼叫端 (子節點) 的時間資訊。
|
自身時間 |
子項時間 |
總計 |
在「Bottom Up」樹狀圖頂端 (頂端節點) 的方法或函式 |
代表方法或函式執行程式碼 (而非受呼叫者) 的總時間長度。相較於「Top Down」樹狀圖,此時間資訊代表在記錄期間,對這個方法或函式發出的所有呼叫總數。 |
代表方法或函式執行呼叫端的總時間長度,而非其程式碼。相較於「Top Down」樹狀圖,這項時間資訊代表在這段錄製期間,對這個方法或函式的呼叫端的所有呼叫總和。 |
自身時間和子項時間的總和。 |
呼叫端 (子節點) |
代表受呼叫者被呼叫端呼叫的總時間。以圖 6 的「Bottom Up」樹狀圖為例,方法 B 的自身時間將等於方法 C 被 B 呼叫時,每次執行的自身時間總和。 |
代表呼叫端叫用時受呼叫者的子項總時長。以圖 6 的「Bottom Up」為例,方法 B 的子項時間將等於方法 C 被 B 呼叫時,每次執行的子項時間總和。 |
自身時間和子項時間的總和。 |
注意:對於錄音檔,當分析器的檔案大小達到該上限,Android Studio 就會停止收集新資料 (但並不會停止錄製)。執行追蹤記錄時,通常會更快完成這項作業,因為相較於取樣追蹤記錄,這種類型的追蹤記錄會在較短的時間內收集更多資料。如果您將檢查時間延伸至上限後產生的記錄時段,追蹤記錄窗格中的時間資料並不會改變 (因為沒有可用的新資料)。此外,如果您選取的記錄檔資料中沒有可用的資料,追蹤記錄窗格會顯示時間資訊的「NaN」。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# Top down and bottom up charts\n\nThe **Top Down** tab displays a list of calls in which expanding a method or\nfunction node displays its callees. Figure 2 shows a top down graph for the\nfollowing call chart. Each arrow in the graph points from a caller to a callee.\n\n\n**Figure 1.** An example call chart that illustrates\nself, children, and total time for method D.\n\n\u003cbr /\u003e\n\nAs shown in Figure 2, expanding the node for method A in the **Top Down** tab\ndisplays its callees, methods B and D. After that, expanding the node for method\nD exposes its callees, such as methods B and C. Similar to the\n[**Flame chart**](/studio/profile/chart-glossary/flame-chart) tab, the top down\ntree aggregates trace information for identical methods that share the same call\nstack. That is, the **Flame chart** tab provides a graphical representation of\nthe **Top Down** tab.\n\nThe **Top Down** tab provides the following information to help describe CPU\ntime spent on each call (times are also represented as a percentage of the\nthread's total time over the selected range):\n\n- **Self:** the time the method or function call spent executing its own code and not that of its callees, as illustrated in Figure 1 for method D.\n- **Children:** the time the method or function call spent executing its callees and not its own code, as illustrated in Figure 1 for method D.\n- **Total:** the sum of the method's **Self** and **Children** time. This represents the total time the app spent executing a call, as illustrated in Figure 1 for method D.\n\n**Figure 2.** A Top Down tree.\n\n\u003cbr /\u003e\n\n**Figure 3.** A Bottom Up tree for method C from\nFigure 5.\n\n\u003cbr /\u003e\n\nThe **Bottom Up** tab displays a list of calls in which expanding a function or\nmethod's node displays its callers. Using the example trace shown in Figure 2,\nfigure 3 provides a bottom up tree for method C. Opening the node for method C\nin the bottom up tree displays each of its unique callers, methods B and D. Note\nthat, although B calls C twice, B appears only once when expanding the node for\nmethod C in the bottom up tree. After that, expanding the node for B displays\nits caller, methods A and D.\n\nThe **Bottom Up** tab is useful for sorting methods or functions by those that\nconsume the most (or least) CPU time. You can inspect each node to determine\nwhich callers spend the most CPU time invoking those methods or functions.\nCompared to the top down tree, timing info for each method or function in a\nbottom up tree is in reference to the method at the top of each tree (top node).\nCPU time is also represented as a percentage of the thread's total time during\nthat recording. The following table helps explain how to interpret timing\ninformation for the top node and its callers (sub-nodes).\n\n| | Self | Children | Total |\n| Method or function at the top of the bottom up tree (top node) | Represents the total time the method or function spent executing its own code and not that of its callees. Compared to the top down tree, this timing information represents a sum of all calls to this method or function over the duration of the recording. | Represents the total time the method or function spent executing its callees and not its own code. Compared to the top down tree, this timing information represents the sum of all calls to this method or function's callees over the duration of the recording. | The sum of the self time and children time. |\n| Callers (sub-nodes) | Represents the total self time of the callee when being called by the caller. Using the bottom up tree in Figure 6 as an example, the self time for method B would equal the sum of the self times for each execution of method C when called by B. | Represents the total children time of the callee when being invoked by the caller. Using the bottom up tree in Figure 6 as an example, the children time for method B would equal the sum of the children times for each execution of method C when called by B. | The sum of the self time and children time. |\n|----------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|\n\n\n**Note:** For a given recording, Android Studio stops collecting new data\nwhen the profiler reaches the file size limit (however, this does not stop the\nrecording). This typically happens much more quickly when performing\ninstrumented traces because this type of tracing collects more data in a shorter\ntime, compared to a sampled trace. If you extend the inspection time into a\nperiod of the recording that occurred after reaching the limit, timing data in\nthe trace pane does not change (because no new data is available). Additionally,\nthe trace pane displays **NaN** for timing information when you select only\nthe portion of a recording that has no data available."]]