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
title: "Run profiling tools with or without the debugger | Microsoft Docs"
3
-
ms.date: "11/04/2018"
3
+
ms.date: "5/26/2020"
4
4
ms.topic: "conceptual"
5
5
ms.assetid: 3fcdccad-c1bd-4c67-bcec-bf33a8fb5d63
6
6
author: "mikejo5000"
@@ -11,115 +11,150 @@ ms.workload:
11
11
---
12
12
# Run profiling tools with or without the debugger
13
13
14
-
Visual Studio offers a choice of performance measurement and profiling tools. Some tools, like **CPU Usage** and **Memory Usage**, can run with or without the debugger, and on Release or Debug build configurations. **Performance Profiler** tools like **Application Timeline** can run on Debug or Release builds. Debugger-integrated tools like the **Diagnostic Tools** window and **Events** tab run only during debugging sessions.
14
+
Visual Studio offers a choice of performance measurement and profiling tools. Some tools, like CPU Usage and Memory Usage, can run with or without the debugger, and on release or debug build configurations. Performance Profiler tools like Application Timeline can run on debug or release builds. Debugger-integrated tools, like the Diagnostic Tools window and Events tab, run only during debugging sessions.
15
15
16
16
>[!NOTE]
17
17
>You can use the non-debugger performance tools with Windows 7 and later. Windows 8 or later is required to run the debugger-integrated profiling tools.
18
18
19
-
The non-debugger **Performance Profiler** and the debugger-integrated **Diagnostic Tools** provide different information and experiences. Debugger-integrated tools show you breakpoints and variable values. Non-debugger tools give you results closer to the end-user experience.
19
+
The non-debugger Performance Profiler and the debugger-integrated Diagnostic Tools provide different information and experiences. Debugger-integrated tools show you breakpoints and variable values. Non-debugger tools give you results closer to the end-user experience.
20
20
21
-
To help decide which tools and results to use, consider the following points:
21
+
To help decide which tools and results to use, consider the following:
22
22
23
23
- External performance problems, like file I/O or network responsiveness issues, won't look much different in the debugger or non-debugger tools.
24
-
- For issues caused by CPU-intensive calls, there may be considerable performance differences between Release and Debug builds. Check to see whether the issue exists in Release builds.
25
-
- If the issue occurs only during Debug builds, you probably don't need to run the non-debugger tools. For Release build issues, decide whether the debugger tools will help for further investigation.
26
-
- Release builds provide optimizations like inlining function calls and constants, pruning unused code paths, and storing variables in ways that can't be used by the debugger. Performance numbers in the debugger-integrated tools are less accurate, because Debug builds lack these optimizations.
27
-
- The debugger itself changes performance times as it does necessary debugger operations like intercepting exception and module load events.
28
-
- Release build performance numbers in the **Performance Profiler** tools are the most precise and accurate. Debugger-integrated tool results are most useful to compare with other debugging-related measurements.
24
+
- For problems caused by CPU-intensive calls, there might be considerable performance differences between release and debug builds. Check to see whether the issue exists in release builds.
25
+
- If the problem occurs only during debug builds, you probably don't need to run the non-debugger tools. For release build problems, decide whether the debugger tools will help for further investigation.
26
+
- Release builds provide optimizations like inlining function calls and constants, pruning unused code paths, and storing variables in ways that can't be used by the debugger. Performance numbers in the debugger-integrated tools are less accurate, because debug builds lack these optimizations.
27
+
- The debugger itself changes performance times, as it does necessary debugger operations like intercepting exception and module load events.
28
+
- Release build performance numbers in the Performance Profiler tools are the most precise and accurate. Debugger-integrated tool results are most useful to compare with other debugging-related measurements.
29
29
30
30
## <aname="BKMK_Quick_start__Collect_diagnostic_data"></a> Collect profiling data while debugging
31
31
32
-
When you start debugging in Visual Studio by selecting **Debug** > **Start Debugging** or pressing **F5**, the **Diagnostic Tools** window appears by default. To open it manually, select **Debug** > **Windows** > **Show Diagnostic Tools**. The **Diagnostic Tools** window shows information about events, process memory, and CPU usage.
32
+
When you start debugging in Visual Studio by selecting **Debug** > **Start Debugging**, or pressing **F5**, the **Diagnostic Tools** window appears by default. To open it manually, select **Debug** > **Windows** > **Show Diagnostic Tools**. The **Diagnostic Tools** window shows information about events, process memory, and CPU usage.

35
35
36
36
- Use the **Settings** icon in the toolbar to select whether to view **Memory Usage**, **UI Analysis**, and **CPU Usage**.
37
37
38
-
- Select **Settings** in the **Settings**dropdown to open the **Diagnostic Tools Property Pages** with more options.
38
+
- Select **Settings** in the **Settings**drop-down list to open the **Diagnostic Tools Property Pages** with more options.
39
39
40
-
- If you're running Visual Studio Enterprise, you can enable or disable IntelliTrace under Visual Studio**Tools** > **Options** > **IntelliTrace**.
40
+
- If you're running Visual Studio Enterprise, you can enable or disable IntelliTrace by going to**Tools** > **Options** > **IntelliTrace**.
41
41
42
42
The diagnostic session ends when you stop debugging.
43
43
44
-
You can also view **Diagnostic Tools** for remote debugging targets. For remote debugging and profiling, the Visual Studio remote debugger must be installed and running on the remote target.
45
-
- For remote debugging and profiling desktop app projects, see [Remote debugging](../debugger/remote-debugging.md).
46
-
- For remote debugging and profiling UWP apps, see [Debug UWP apps on remote machines](../debugger/run-windows-store-apps-on-a-remote-machine.md).
47
-
48
44
### The Events tab
49
45
50
-
During a debugging session, the **Events** tab of the **Diagnostic Tools** window lists the diagnostic events that occur. The category prefixes: **Breakpoint**, **File**, and others, let you quickly scan the list for a category, or skip the categories you don't care about.
46
+
During a debugging session, the Events tab of the Diagnostic Tools window lists the diagnostic events that occur. The category prefixes*Breakpoint*, *File*, and others, let you quickly scan the list for a category, or skip the categories you don't care about.
51
47
52
-
Use the **Filter**dropdown to filter events in and out of view by selecting or deselecting specific categories of events.
48
+
Use the **Filter**drop-down list to filter events in and out of view, by selecting or clearing specific categories of events.

59
55
60
56
For more information, see [Searching and filtering the Events tab of the Diagnostic Tools window](https://devblogs.microsoft.com/devops/searching-and-filtering-the-events-tab-of-the-diagnostic-tools-window/).
61
57
62
58
## Collect profiling data without debugging
63
59
64
-
To collect performance data without debugging, you can run the **Performance Profiler** tools. Some of the profiling tools require administrator privileges to run. You can open Visual Studio as an administrator, or you can run the tools as an administrator when you start the diagnostic session.
60
+
To collect performance data without debugging, you can run the Performance Profiler tools.
61
+
62
+
1. With a project open in Visual Studio, set the solution configuration to **Release**, and select **Local Windows Debugger** (or **Local Machine**) as the deployment target.
65
63
66
-
1.With a project open in Visual Studio, select**Debug** > **Performance Profiler**, or press **Alt**+**F2**.
64
+
1.Select**Debug** > **Performance Profiler**, or press **Alt**+**F2**.
67
65
68
-
1. On the diagnostic launch page, select one or more tools to run. Only the tools that are applicable to the project type, operating system, and programming language are displayed. Select **Show all tools** to also see tools that are disabled for this diagnostic session. Here's how your choices might look for a C# UWP app:
66
+
1. On the diagnostic tools launch page, select one or more tools to run. Only the tools that are applicable to the project type, operating system, and programming language are shown. Select **Show all tools** to also see tools that are disabled for this diagnostic session.
69
67
70
-

68
+

71
69
72
70
1. To start the diagnostic session, select **Start**.
73
71
74
-
While the session is running, some tools display graphs of real-time data on the diagnostic tools page.
72
+
While the session is running, some tools show graphs of real-time data on the diagnostic tools page, as well as controls to pause and resume data collection.
75
73
76
-

74
+

77
75
78
76
1. To end the diagnostic session, select **Stop Collection**.
79
77
80
-
The analyzed data displays on the **Report** page.
78
+
The analyzed data appears on the **Report** page.
79
+
80
+
You can save the reports, and open them from the **Recently Opened Sessions** list on the Diagnostic Tools launch page.
81
+
82
+

83
+
84
+
## Collect profiling data from the command line
85
+
86
+
To measure performance data from the command line, you can use VSDiagnostics.exe, which is included with either Visual Studio or the Remote Tools. This is useful for capturing performance traces on systems where Visual Studio isn't installed, or for scripting the collection of performance traces. When you use VSDiagnostics.exe, you begin a diagnostic session that captures and stores profiling data until the tool is stopped. At that point, that data is exported into a .diagsession file, and you can open this file in Visual Studio to analyze results.
87
+
88
+
### Launch an application
89
+
90
+
1. Open a command prompt, and change to the directory with VSDiagnostics.exe:
91
+
92
+
```
93
+
<Visual Studio Install Folder>\Team Tools\DiagnosticsHub\Collector\
94
+
```
95
+
96
+
2. Start VSDiagnostics.exe with the following command:
- <id>: Identifies the collection session. The ID must be a number between 1-255.
105
+
- <appToLaunch>: The executable file to launch and profile.
106
+
- <configFile>: The configuration file for the collection agent you want to launch.
107
+
108
+
3. To stop collection and view your results, follow the steps in the "Stop collection" section later in this article.
81
109
82
-
You can save the reports, and open them from the **Recently Opened Sessions** list on the diagnostic tools launch page.
110
+
### Attach to an existing application
83
111
84
-

112
+
1. Open an application, such as Notepad, and then open **Task Manager** to get its process ID (PID). In Task Manager, find the PID in the **Details** tab.
113
+
2. Open a command prompt, and change to the directory with the collection agent executable. Typically, it's here:
<Visual Studio installation folder>\2019\Preview\Team Tools\DiagnosticsHub\Collector\
117
+
```
88
118
89
-
|||
90
-
|-|-|
91
-
||The timeline shows the length of the profiling session, app lifecycle activation events, and user marks.|
92
-
||You can restrict the report to a part of the timeline by dragging the blue bars to select a region of the timeline.|
93
-
||Each diagnostic tool displays one or more master graphs. If your diagnostic session had more than one tool, all of their master graphs are displayed.|
94
-
||You can collapse and expand each tool's individual graphs.|
95
-
||When the data includes more than one tool, tool details are collected under tabs.|
96
-
||The bottom half of the report shows one or more detail views for each tool. You can filter the view by selecting regions of the timeline.|
119
+
3. Start the VSDiagnostics.exe file by typing the following command.
97
120
98
-
## Run diagnostic sessions on installed or running apps
Besides starting your app from the Visual Studio project, you can also run diagnostic sessions on alternative targets. For example, you might want to diagnose performance issues on an app that was installed from the Windows App Store.
- <id>: Identifies the collection session. The ID must be a number between 1-255.
128
+
- <pid>: The PID of the process you want to profile, which in this case is the PID you found in step 1.
129
+
- <configFile>: The configuration file for the collection agent you want to launch. For more information, see [Configuration files for agents](../profiling/profile-apps-from-command-line.md).
103
130
104
-
You can start apps that are already installed, or attach the diagnostic tools to apps and processes that are already running. When you select **Running App** or **Installed App**, you select the app from a list that finds the apps on the specified deployment target. This target can be a local or remote machine.
131
+
4. To stop collection and view your results, follow the steps in the next section.
105
132
106
-

133
+
### Stop collection
107
134
108
-
## See also
135
+
1. Stop the collection session, and send output to a file, by typing the following command.
109
136
110
-
The following are blog posts and MSDN articles from the Diagnostics development team:
111
-
-[MSDN Magazine: Analyze Performance While Debugging in Visual Studio 2015](https://msdn.microsoft.com/magazine/dn973013.aspx)
137
+
```
138
+
VSDiagnostics.exe stop <id> /output:<path to file>
139
+
```
112
140
113
-
-[MSDN Magazine: Use IntelliTrace to Diagnose Issues Faster](https://msdn.microsoft.com/magazine/dn973014.aspx)
141
+
2. Go to the file output from the previous command, and open it in Visual Studio to examine the information collected.
114
142
115
-
-[Blog post: Diagnosing Event Handler Leaks with the Memory Usage Tool in Visual Studio 2015](https://devblogs.microsoft.com/devops/diagnosing-event-handler-leaks-with-the-memory-usage-tool-in-visual-studio-2015/)
143
+
## Agent configuration files
116
144
117
-
-[Video: Historical Debugging with IntelliTrace in Microsoft Visual Studio Ultimate 2015](https://channel9.msdn.com/Events/Ignite/2015/BRK3716)
145
+
Collection agents are interchangeable components that collect different types of data, depending on what you are trying to measure.
146
+
For convenience, you can store that information in an agent configuration file. The configuration file is a .json file that contains, at minimum, the name of the .dll file and its COM CLSID. Here are the example configuration files that you can find in the following folder:
118
147
119
-
-[Video: Debugging Performance Issues Using Visual Studio 2015](https://channel9.msdn.com/Events/Build/2015/3-731)
148
+
```
149
+
<Visual Studio installation folder>\Team Tools\DiagnosticsHub\Collector\AgentConfigs\
150
+
```
120
151
121
-
-[PerfTips: Performance Information at-a-glance while Debugging with Visual Studio](https://devblogs.microsoft.com/devops/perftips-performance-information-at-a-glance-while-debugging-with-visual-studio/)
152
+
- CpuUsage configurations (Base/High/Low), which corresponds to data collected for the [CPU Usage](../profiling/cpu-usage.md) profiling tool.
153
+
- DotNetObjectAlloc configurations (Base/Low), which corresponds to data collected for the [.NET Object Allocation tool](../profiling/dotnet-alloc-tool.md).
122
154
123
-
-[Diagnostic Tools debugger window in Visual Studio 2015](https://devblogs.microsoft.com/devops/diagnostic-tools-debugger-window-in-visual-studio-2015/)
155
+
Base/Low/High configurations refer to the sampling rate. For example, Low is 100 samples/second and High is 4000 samples/second.
156
+
For the VSDiagnostics.exe tool to work with a collection agent, it requires both a DLL and a COM CLSID for the appropriate agent. The agent might also have additional configuration options. If you use an agent without a configuration file, use the format in the following command:
124
157
125
-
-[IntelliTrace in Visual Studio Enterprise 2015](https://devblogs.microsoft.com/devops/intellitrace-in-visual-studio-ultimate-2015/)
0 commit comments