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
Copy file name to clipboardExpand all lines: docs/debugger/navigating-through-code-with-the-debugger.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -237,7 +237,7 @@ To load symbols for a specific system component:
237
237
238
238
## <aname="BKMK_Step_into_properties_and_operators_in_managed_code"></a> Step into properties and operators in managed code
239
239
240
-
The debugger steps over properties and operators in managed code by default. In most cases, this behavior provides a better debugging experience. To disable stepping into properties or operators, select **Debug** > **Options**. On the **Debugging** > **General** page, clear the **Step over properties and operators (Managed only)** checkbox.
240
+
The debugger steps over properties and operators in managed code by default. In most cases, this behavior provides a better debugging experience. To enable stepping into properties or operators, select **Debug** > **Options**. On the **Debugging** > **General** page, clear the **Step over properties and operators (Managed only)** checkbox.
241
241
242
242
## <aname="BKMK_Set_the_next_statement_to_execute"></a> Move the pointer to change the execution flow
> Alternatively, we can save time and let Copilot [do the research](#get-copilot-to-do-the-research) for us.
133
+
132
134
If you see performance issues related to database queries, you can use the [Database tool](../profiling/analyze-database.md) to investigate whether certain calls are slower. This data might indicate an opportunity to optimize queries. For a tutorial that shows how to use the Database tool to investigate a performance issue, see [Case study: Beginner's guide to optimizing code](../profiling/optimize-code-using-profiling-tools.md). The Database tool supports .NET Core with either ADO.NET or Entity Framework Core.
133
135
134
136
To get visualizations in Visual Studio for individual thread behavior, you can use the [Parallel Stacks](../debugger/get-started-debugging-multithreaded-apps.md#ParallelStacks) window while debugging. This window shows individual threads along with information about threads that are waiting, threads they're waiting on, and [deadlocks](../debugger/using-the-parallel-stacks-window.md#stack-frame-icons).
135
137
136
138
For additional information on thread pool starvation, see [Detecting threadpool starvation](/dotnet/core/diagnostics/debug-threadpool-starvation#detecting-threadpool-starvation).
137
139
140
+
## Get Copilot to do the research
141
+
142
+
If we're using Copilot, we can ask Copilot to research performance issues for us. Select **Ask Copilot** from the context menu and type the following question:
143
+
144
+
```cmd
145
+
Can you identify a performance issue in the QueryCustomerDB method?
146
+
```
147
+
148
+
> [!TIP]
149
+
> You can use slash commands such as [/optimize](../ide/copilot-chat-context.md#slash-commands) to help form good questions for Copilot.
150
+
151
+
In this example, Copilot gives the following code suggestion, the same answer we previously identified by research, along with an explanation.
Copy file name to clipboardExpand all lines: docs/profiling/optimize-code-using-profiling-tools.md
+32-1Lines changed: 32 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Beginner's guide to optimizing code"
3
3
description: "Learn how to optimize code and reduce compute costs using Visual Studio profiling tools such as the CPU Usage tool, the .NET Object Allocation tool, and the Database tool."
4
-
ms.date: 08/09/2024
4
+
ms.date: 09/20/2024
5
5
ms.topic: conceptual
6
6
ms.custom: "profiling-seo"
7
7
dev_langs:
@@ -138,6 +138,9 @@ This code uses `foreach` loops to search the database for any blogs with "Fred S
138
138
139
139
We do a little research and find some common recommendations for how to optimize LINQ queries and come up with this code.
140
140
141
+
> [!TIP]
142
+
> Alternatively, we can save time and let Copilot [do the research](#optimize-code-with-copilot) for us.
@@ -152,6 +155,34 @@ In this code, we made several changes to help optimize the query:
152
155
153
156
Next, we retest using the profiling tools.
154
157
158
+
### Optimize code with Copilot
159
+
160
+
If we're using Copilot, we can ask Copilot to research performance issues for us. Select **Ask Copilot** from the context menu and type the following question:
161
+
162
+
```cmd
163
+
Can you make the LINQ query in this method faster?
164
+
```
165
+
166
+
> [!TIP]
167
+
> You can use slash commands such as [/optimize](../ide/copilot-chat-context.md#slash-commands) to help form good questions for Copilot.
168
+
169
+
In this example, Copilot gives the following suggested code changes, similar to our optimized query, along with an explanation.
170
+
171
+
```csharp
172
+
publicvoidGetBlogTitleX()
173
+
{
174
+
varposts=db.Posts
175
+
.Where(post=>post.Author=="Fred Smith")
176
+
.Select(post=>post.Title)
177
+
.ToList();
178
+
179
+
foreach (varpostTitleinposts)
180
+
{
181
+
Console.WriteLine($"Post: {postTitle}");
182
+
}
183
+
}
184
+
```
185
+
155
186
## Results
156
187
157
188
After updating the code, we re-run the CPU Usage tool to collect a trace. The **Call Tree** view shows that `GetBlogTitleX` is running only 1754 ms, using 37% of the app's CPU total, a significant improvement from 59%.
0 commit comments