Skip to content

Commit a440ea4

Browse files
committed
Merged main into live
2 parents ed8be4c + a85bac3 commit a440ea4

File tree

3 files changed

+62
-8
lines changed

3 files changed

+62
-8
lines changed

docs/debugger/navigating-through-code-with-the-debugger.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ To load symbols for a specific system component:
237237

238238
## <a name="BKMK_Step_into_properties_and_operators_in_managed_code"></a> Step into properties and operators in managed code
239239

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.
241241

242242
## <a name="BKMK_Set_the_next_statement_to_execute"></a> Move the pointer to change the execution flow
243243

docs/profiling/isolate-performance-issue.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Isolate a performance issue"
33
description: "Learn how to use .NET Counters and the Instrumentation tools to identify, isolate, and resolve performance issues."
4-
ms.date: 09/03/2024
4+
ms.date: 09/20/2024
55
ms.topic: conceptual
66
dev_langs:
77
- "CSharp"
@@ -111,9 +111,8 @@ Double-click the `QueryCustomerDB` function to show the source code for the func
111111
```csharp
112112
public ActionResult<string> QueryCustomerDB()
113113
{
114-
115-
Task dbTask = QueryCustomerFromDbAsync("Dana");
116-
return "success:tasksleepwait";
114+
Customer c = QueryCustomerFromDbAsync("Dana").Result;
115+
return "success:taskwait";
117116
}
118117
```
119118

@@ -122,19 +121,43 @@ With a little research, we discover that this code is calling an async API witho
122121
To resolve, use await.
123122

124123
```csharp
125-
public async Task<ActionResult<string>> TaskAsyncWait()
124+
public async Task<ActionResult<string>> QueryCustomerDB()
126125
{
127-
Customer c = await PretendQueryCustomerFromDbAsync("Dana");
126+
Customer c = await QueryCustomerFromDbAsync("Dana");
128127
return "success:taskasyncwait";
129128
}
130129
```
131130

131+
> [!TIP]
132+
> Alternatively, we can save time and let Copilot [do the research](#get-copilot-to-do-the-research) for us.
133+
132134
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.
133135

134136
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).
135137

136138
For additional information on thread pool starvation, see [Detecting threadpool starvation](/dotnet/core/diagnostics/debug-threadpool-starvation#detecting-threadpool-starvation).
137139

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.
152+
153+
```csharp
154+
public async Task<ActionResult<string>> QueryCustomerDB()
155+
{
156+
Customer c = await QueryCustomerFromDbAsync("Dana");
157+
return "success:taskwait";
158+
}
159+
```
160+
138161
## Next steps
139162

140163
The following articles and blog posts provide more information to help you learn to use the Visual Studio performance tools effectively.

docs/profiling/optimize-code-using-profiling-tools.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Beginner's guide to optimizing code"
33
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
55
ms.topic: conceptual
66
ms.custom: "profiling-seo"
77
dev_langs:
@@ -138,6 +138,9 @@ This code uses `foreach` loops to search the database for any blogs with "Fred S
138138

139139
We do a little research and find some common recommendations for how to optimize LINQ queries and come up with this code.
140140

141+
> [!TIP]
142+
> Alternatively, we can save time and let Copilot [do the research](#optimize-code-with-copilot) for us.
143+
141144
```csharp
142145
foreach (var x in db.Posts.Where(p => p.Author.Contains("Fred Smith")).Select(b => b.Title).ToList())
143146
{
@@ -152,6 +155,34 @@ In this code, we made several changes to help optimize the query:
152155

153156
Next, we retest using the profiling tools.
154157

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+
public void GetBlogTitleX()
173+
{
174+
var posts = db.Posts
175+
.Where(post => post.Author == "Fred Smith")
176+
.Select(post => post.Title)
177+
.ToList();
178+
179+
foreach (var postTitle in posts)
180+
{
181+
Console.WriteLine($"Post: {postTitle}");
182+
}
183+
}
184+
```
185+
155186
## Results
156187

157188
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

Comments
 (0)