You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
added additional content for using the cpu usage tool, how its helpful (#9800)
* added additional content for using the cpu usage tool, how its helpful
* added the shortcut info
* added new screenshots, removed outdated text
* edited md file to reflect pr comments
* changed underscores to hyphens in png images
* updated image names in md file, updated image with steps in lines 79-82, fixed line 96, fixed line 115
Co-authored-by: Misty Hays <[email protected]>
Copy file name to clipboardExpand all lines: docs/profiling/cpu-usage.md
+18-18Lines changed: 18 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,11 @@ ms.workload:
14
14
---
15
15
# Analyze CPU usage without debugging in the Performance Profiler (C#, Visual Basic, C++, F#)
16
16
17
-
A good way to start investigating performance issues in your app is to understand its CPU usage. The **CPU Usage** performance tool shows the CPU time and percentage spent executing code in C++, C#/Visual Basic, and JavaScript apps.
17
+
A good way to start investigating performance issues in your app is to understand its CPU usage. The **CPU Usage** performance tool shows the CPU time and percentage spent executing code in C++, C#/Visual Basic, and JavaScript apps. If you need to diagnose a slow-down or a process hang in your team’s codebase, the CPU Usage tool can help you diagnose the issue with your team’s production code. The tool provides automatic insights and various views of your data so that you can analyze and diagnose performance issues.
18
+
19
+
The tool is also helpful for DevOps scenarios, such as when a customer reports that some requests or orders are not getting through to the retail website during peak season. Often, the issues are in production, and it is challenging to debug at that moment, but this tool can help you capture enough information and evidence of the issue. After collecting a trace file, the analysis can quickly help you understand potential causes and give suggestions within the context of your code so that you can take the next steps to fix the issue.
20
+
21
+
The **CPU Usage** tool is helpful for both local trace sessions and production. It can also be initiated by using the keyboard shortcut, **Alt+F2**, and then **CPU Usage** or by opening an already collected trace using a tool like dotnet-trace or dotnet-monitor.
18
22
19
23
The CPU Usage tool can run on an open Visual Studio project, on an installed Microsoft Store app, or attached to a running app or process. You can run the CPU Usage tool with or without debugging. For more information, see [Run profiling tools with or without the debugger](../profiling/running-profiling-tools-with-or-without-the-debugger.md).
20
24
@@ -29,21 +33,21 @@ Usually, the local machine best replicates installed app execution. To collect d
29
33
30
34
1. In the Visual Studio project, set the solution configuration to **Release** and select **Local Windows Debugger** (or **Local Machine**) as the deployment target.
31
35
32
-

36
+

33
37
34
38
1. Select **Debug** > **Performance Profiler**.
35
39
36
40
1. Under **Available tools**, select **CPU Usage**, and then select **Start**.
37
41
38
-

42
+

39
43
40
44
4. After the app starts, the diagnostic session begins and displays CPU usage data. When you're finished collecting data, select **Stop Collection**.
41
45
42
-

46
+

43
47
44
48
The CPU Usage tool analyzes the data and displays the report.
@@ -68,10 +72,10 @@ To view the call tree, select the parent node in the report. The **CPU Usage** p
68
72
#### <aname="BKMK_Call_tree_structure"></a> Call tree structure
69
73
70
74
::: moniker range=">=vs-2019"
71
-

75
+

72
76
::: moniker-end
73
77
::: moniker range="vs-2017"
74
-

78
+

75
79
::: moniker-end
76
80
77
81
|Image|Description|
@@ -85,34 +89,30 @@ To view the call tree, select the parent node in the report. The **CPU Usage** p
85
89
86
90
System and framework functions that are executed by your code are called *external code*. External code functions start and stop the app, draw the UI, control threading, and provide other low-level services to the app. In most cases, you aren't interested in external code, so the CPU Usage call tree gathers the external functions of a user method into one **[External Code]** node.
87
91
88
-
To view the call paths of external code, on the main diagnostic report page (right pane), select **Show External Code**from the **Filter** dropdown, and then select **Apply**. The **Call Tree** view of the **CPU Usage** page then expands the external code calls. (The **Filter** dropdown is available on the main diagnostic page, not the detailed views.)
92
+
To view the call paths of external code, switch the current view to the **Call Tree**view or right-click and select **View in Call Tree**.
Many external code call chains are deeply nested, so the width of the chain can exceed the display width of the **Function Name** column. The function names then appear as **...**.
96
+
Many external code call chains are deeply nested, so the width of the chain can exceed the display width of the **Function Name** column. The function names then appear as shown in the following image.
93
97
94
-

98
+

95
99
96
100
To find a function name you're looking for, use the search box. Hover over the selected line or use the horizontal scroll bar to view the data.
97
101
98
102
::: moniker range=">=vs-2019"
99
-

103
+

100
104
::: moniker-end
101
105
::: moniker range="vs-2017"
102
-

106
+

103
107
::: moniker-end
104
108
105
109
### <aname="BKMK_Asynchronous_functions_in_the_CPU_Usage_call_tree"></a> Asynchronous functions in the CPU usage call tree
106
110
107
111
When the compiler encounters an asynchronous method, it creates a hidden class to control the method's execution. Conceptually, the class is a state machine. The class has compiler-generated functions that asynchronously call the original methods, and the callbacks, scheduler, and iterators needed to run them. When a parent method calls the original method, the compiler removes the method from the execution context of the parent, and runs the hidden class methods in the context of the system and framework code that controls app execution. The asynchronous methods are often, but not always, executed on one or more different threads. This code appears in the **CPU Usage** call tree as children of the **[External Code]** node immediately below the top node of the tree.
108
112
109
-
In the following example, the first two nodes under **[External Code]** are the compiler-generated methods of the state machine class. The third node is the call to the original method.
0 commit comments