Skip to content

Commit 0a4c605

Browse files
Merge pull request #14077 from MicrosoftDocs/main
Merged by Learn.Build PR Management system
2 parents dc1196e + 368e4c0 commit 0a4c605

File tree

26 files changed

+71
-79
lines changed

26 files changed

+71
-79
lines changed

docs/ide/reference/options-text-editor-csharp-advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Select these check boxes to display dotted vertical lines between the curly brac
149149

150150
- Don't put ref or out on custom struct
151151

152-
Uncheck this checkbox to avoid potentially unintended cloning of structs by refencing existing struct objects when extracting an expression into a method call.
152+
Uncheck this checkbox to avoid potentially unintended cloning of structs by referencing existing struct objects when extracting an expression into a method call.
153153

154154
### Example
155155

docs/profiling/isolate-performance-issue.md

Lines changed: 21 additions & 24 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: 3/26/2025
4+
ms.date: 7/3/2025
55
ms.topic: conceptual
66
dev_langs:
77
- "CSharp"
@@ -18,52 +18,49 @@ monikerRange: '>= vs-2022'
1818

1919
# Case study: Isolate a performance issue (C#, Visual Basic, F#)
2020

21-
Use the profiling tools to investigate performance issues and isolate problem areas. This case study uses a sample application with performance issues to demonstrate how to use profiling tools to improve efficiency. If you want to compare profiling tools, see [Which tool should I choose?](../profiling/choose-performance-tool.md)
21+
This case study demonstrates how to use Visual Studio profiling tools to identify and resolve performance issues in a sample ASP.NET application. For a comparison of profiling tools, see [Which tool should I choose?](../profiling/choose-performance-tool.md)
2222

23-
This case study covers these topics:
23+
You'll learn:
2424

2525
- How to use Visual Studio profiling tools to analyze application performance.
26-
- How to interpret the data provided by these tools to identify performance bottlenecks.
27-
- How to apply practical strategies to optimize code, focusing on .NET Counters, call counts, and timing data.
26+
- How to interpret profiling data to find bottlenecks.
27+
- Practical strategies for optimizing code using .NET Counters, call counts, and timing data.
2828

29-
Follow along and then apply these techniques to your own applications to make them more efficient and cost-effective.
29+
Apply these techniques to improve your own applications.
3030

3131
## Isolate a performance issue case study
3232

33-
The sample application in this case study is an ASP.NET app that runs queries against a simulated database. The example is based on the [Diagnostics Sample](/dotnet/core/diagnostics/debug-threadpool-starvation).
33+
The sample ASP.NET app runs queries against a simulated database and is based on the [Diagnostics Sample](/dotnet/core/diagnostics/debug-threadpool-starvation).
3434

35-
The primary performance issue with the sample application lies in inefficient coding patterns. The application has a performance bottleneck that significantly impacts its efficiency. The problem includes the following symptoms:
35+
Key performance symptoms:
3636

37-
- **Low CPU Usage**: The application shows low CPU usage, indicating that the CPU is not the bottleneck.
37+
- **Low CPU Usage**: The CPU is not the bottleneck.
38+
- **High ThreadPool Thread Count**: Thread count rises steadily, indicating thread pool starvation.
39+
- **Slow Application Response**: The app responds slowly due to a lack of available threads.
3840

39-
- **High ThreadPool Thread Count**: The thread count is relatively high and steadily rising, suggesting thread pool starvation.
40-
41-
- **Slow Application Response**: The application responds slowly due to the lack of available threads to process new work items.
42-
43-
The case study aims to address these issues by employing Visual Studio's profiling tools to analyze the application's performance. By understanding where and how the application's performance can be improved, developers can implement optimizations to make code faster and more efficient. The ultimate goal is to enhance the application's overall performance, making it more efficient and cost-effective to run.
41+
This case study uses Visual Studio profiling tools to pinpoint and address these issues, helping you make your code faster and more efficient.
4442

4543
## Challenge
4644

47-
Addressing the performance issues in the sample .NET application presents several challenges. These challenges stem from the complexity of diagnosing performance bottlenecks. The key challenges in fixing the problems described are as follows:
48-
49-
- **Diagnosing Performance Bottlenecks**: One of the primary challenges is accurately identifying the root causes of the performance issues. Low CPU usage combined with slow performance can have multiple contributing factors. Developers must use profiling tools effectively to diagnose these issues, which requires some understanding of how these tools work and how to interpret their output.
45+
Fixing these issues involves several challenges:
5046

51-
- **Knowledge and Resource Constraints**: Teams may face constraints related to knowledge, expertise, and resources. Profiling and optimizing an application requires specific skills and experience, and not all teams may have immediate access to these resources.
47+
- **Diagnosing Bottlenecks**: Low CPU usage with slow performance can have multiple causes. Effective use of profiling tools and interpreting their output is essential.
48+
- **Knowledge and Resource Constraints**: Profiling and optimization require specific skills and experience, which may not always be available.
5249

53-
Addressing these challenges requires a strategic approach that combines effective use of profiling tools, technical knowledge, and careful planning and testing. The case study aims to guide developers through this process, providing strategies and insights to overcome these challenges and improve the application's performance.
50+
A strategic approach combining profiling tools, technical knowledge, and careful testing is key to overcoming these challenges.
5451

5552
## Strategy
5653

5754
Here is a high-level view of the approach in this case study:
5855

59-
- We start the investigation by watching .NET counter metrics while collecting performance data. Like the CPU Usage tool, Visual Studio's [.NET Counters](../profiling/dotnet-counters-tool.md) tool is also a good starting point for a performance investigation.
60-
- Next, for additional insights to help isolate issues or improve the performance, consider collecting a trace using one of the other profiling tools. For example, take a look at call counts and timing data using the [Instrumentation](../profiling/instrumentation.md) tool.
56+
- Start by monitoring .NET counter metrics while collecting performance data. Visual Studio's [.NET Counters](../profiling/dotnet-counters-tool.md) tool is a good starting point.
57+
- For deeper insights, collect traces with additional profiling tools, such as the [Instrumentation](../profiling/instrumentation.md) tool for call counts and timing data.
6158

6259
Data collection requires the following tasks:
6360

64-
- Setting the app to a Release build.
65-
- Select the .NET Counters tool from the Performance Profiler (**Alt+F2**). (Later steps involve the Instrumentation tool.)
66-
- From the Performance Profiler, start the app and collect a trace.
61+
- Set the app to Release build.
62+
- Select the .NET Counters tool in Performance Profiler (**Alt+F2**).
63+
- Start the app and collect a trace.
6764

6865
## Check performance counters
6966

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

Lines changed: 23 additions & 28 deletions
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: 3/26/2025
4+
ms.date: 7/3/2025
55
ms.topic: conceptual
66
ms.custom: "profiling-seo"
77
dev_langs:
@@ -18,55 +18,50 @@ monikerRange: '>= vs-2022'
1818
---
1919
# Case Study: Beginner's guide to optimizing code and reducing compute costs (C#, Visual Basic, C++, F#)
2020

21-
Reducing your compute time means reducing costs, so optimizing your code can save money. This case study uses a sample application with performance issues to demonstrate how to use profiling tools to improve efficiency. If you want to compare profiling tools, see [Which tool should I choose?](../profiling/choose-performance-tool.md)
21+
Optimizing your code reduces compute time and costs. This case study demonstrates how to use Visual Studio profiling tools to identify and fix performance issues in a sample .NET application. If you want to compare profiling tools, see [Which tool should I choose?](../profiling/choose-performance-tool.md)
2222

23-
This case study covers these topics:
23+
This guide covers:
2424

25-
- The importance of code optimization and its impact on reducing compute costs.
26-
- How to use Visual Studio profiling tools to analyze application performance.
27-
- How to interpret the data provided by these tools to identify performance bottlenecks.
28-
- How to apply practical strategies to optimize code, focusing on CPU usage, memory allocation, and database interactions.
25+
- How to use Visual Studio profiling tools to analyze and improve performance.
26+
- Practical strategies for optimizing CPU usage, memory allocation, and database interactions.
2927

30-
Follow along and then apply these techniques to your own applications to make them more efficient and cost-effective.
28+
Apply these techniques to make your own applications more efficient.
3129

3230
## Optimization case study
3331

34-
The sample application examined in this case study is a .NET application that runs queries against a database of blogs and blog posts. It utilizes the Entity Framework, a popular ORM (Object-Relational Mapping) for .NET, to interact with a SQLite local database. The application is structured to execute a large number of queries, simulating a real-world scenario where a .NET application might be required to handle extensive data retrieval tasks. The sample application is a modified version of the [Entity Framework getting started sample](/ef/core/get-started/overview/first-app).
32+
The sample .NET application runs queries against a SQLite database of blogs and posts using Entity Framework. It executes many queries, simulating a real-world data retrieval scenario. The app is based on the [Entity Framework getting started sample](/ef/core/get-started/overview/first-app), but uses a larger dataset.
3533

36-
The primary performance issue with the sample application lies in how it manages compute resources and interacts with the database. The application has a performance bottleneck that significantly impacts its efficiency and, consequently, the compute costs associated with running it. The problem includes the following symptoms:
34+
Key performance issues include:
3735

38-
- **High CPU Usage**: Applications may perform inefficient computations or processing tasks in a way that unnecessarily consumes a large amount of CPU resources. This can lead to slow response times and increased operational costs.
36+
- **High CPU Usage**: Inefficient computations or processing tasks increase CPU consumption and costs.
37+
- **Inefficient Memory Allocation**: Poor memory management leads to excessive garbage collection and reduced performance.
38+
- **Database Overheads**: Inefficient queries and excessive database calls degrade performance.
3939

40-
- **Inefficient Memory Allocation**: Applications can sometimes face issues related to memory usage and allocation. In .NET apps, inefficient memory management can lead to increased garbage collection, which in turn can affect application performance.
41-
42-
- **Database Interaction Overheads**: Applications that execute a large number of queries against a database can experience bottlenecks related to database interactions. This includes inefficient queries, excessive database calls, and poor use of Entity Framework capabilities, all of which can degrade performance.
43-
44-
The case study aims to address these issues by employing Visual Studio's profiling tools to analyze the application's performance. By understanding where and how the application's performance can be improved, developers can implement optimizations to reduce CPU usage, improve memory allocation efficiency, streamline database interactions, and optimize resource utilization. The ultimate goal is to enhance the application's overall performance, making it more efficient and cost-effective to run.
40+
This case study uses Visual Studio profiling tools to pinpoint and address these issues, aiming to make the application more efficient and cost-effective.
4541

4642
## Challenge
4743

48-
Addressing the performance issues in the sample .NET application presents several challenges. These challenges stem from the complexity of diagnosing performance bottlenecks. The key challenges in fixing the problems described are as follows:
49-
50-
- **Diagnosing Performance Bottlenecks**: One of the primary challenges is accurately identifying the root causes of the performance issues. High CPU usage, inefficient memory allocation, and database interaction overheads can have multiple contributing factors. Developers must use profiling tools effectively to diagnose these issues, which requires some understanding of how these tools work and how to interpret their output.
44+
Fixing these performance issues involves several challenges:
5145

52-
- **Knowledge and Resource Constraints**: Finally, teams may face constraints related to knowledge, expertise, and resources. Profiling and optimizing an application requires specific skills and experience, and not all teams may have immediate access to these resources.
46+
- **Diagnosing Bottlenecks**: Identifying root causes of high CPU, memory, or database overheads requires effective use of profiling tools and a correct interpretion of results.
47+
- **Knowledge and Resource Constraints**: Profiling and optimization require specific skills and experience, which may not always be available.
5348

54-
Addressing these challenges requires a strategic approach that combines effective use of profiling tools, technical knowledge, and careful planning and testing. The case study aims to guide developers through this process, providing strategies and insights to overcome these challenges and improve the application's performance.
49+
A strategic approach combining profiling tools, technical knowledge, and careful testing is essential to overcome these challenges.
5550

5651
## Strategy
5752

5853
Here is a high-level view of the approach in this case study:
5954

60-
- We start the investigation by taking a CPU usage trace. Visual Studio's [CPU Usage tool](../profiling/cpu-usage.md) is often helpful to begin performance investigations and to optimize code to reduce cost.
61-
- Next, to get additional insights to help isolate issues or improve the performance, we collect a trace using one of the other profiling tools. For example:
62-
- We take a look at the memory usage. For .NET, we try the [.NET Object Allocation tool](../profiling/dotnet-alloc-tool.md) first. (For either .NET or C++, you can look at the Memory Usage tool instead.)
63-
- For ADO.NET or Entity Framework, we can use the [Database tool](../profiling/analyze-database.md) to examine SQL queries, precise query time, and more.
55+
- Start with a CPU usage trace using Visual Studio's [CPU Usage tool](../profiling/cpu-usage.md). Visual Studio's CPU Usage tool is a good starting point for performance investigations.
56+
- Collect additional traces for memory and database analysis:
57+
- Use the [.NET Object Allocation tool](../profiling/dotnet-alloc-tool.md) for memory insights.
58+
- Use the [Database tool](../profiling/analyze-database.md) to examine SQL queries and timings.
6459

6560
Data collection requires the following tasks:
6661

67-
- Setting the app to a Release build.
68-
- Selecting the CPU Usage tool from the Performance Profiler (**Alt+F2**). (Later steps involve a few of the other tools.)
69-
- From the Performance Profiler, start the app and collect a trace.
62+
- Set the app to Release build.
63+
- Select the CPU Usage tool in Performance Profiler (**Alt+F2**).
64+
- In the Performance Profiler, start the app and collect a trace.
7065

7166
### Inspect areas of high CPU usage
7267

docs/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ void TransformChroma(const D2D1::Matrix3x2F& mat, BYTE *pu, BYTE *pv)
352352
//
353353
// The image conversion functions take the following parameters:
354354
//
355-
// mat Transfomation matrix for chroma values.
355+
// mat Transformation matrix for chroma values.
356356
// rcDest Destination rectangle.
357357
// pDest Pointer to the destination buffer.
358358
// lDestStride Stride of the destination buffer, in bytes.

docs/snippets/cpp/VS_Snippets_Winforms/Classic Application.ThreadException Example/CPP/source.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public ref class Form1: public System::Windows::Forms::Form
7575
private:
7676
System::Windows::Forms::DialogResult ShowThreadExceptionDialog( Exception^ e )
7777
{
78-
String^ errorMsg = "An error occurred please contact the adminstrator with the following information:\n\n";
78+
String^ errorMsg = "An error occurred please contact the administrator with the following information:\n\n";
7979
errorMsg = String::Concat( errorMsg, e->Message, "\n\nStack Trace:\n", e->StackTrace );
8080
return MessageBox::Show( errorMsg, "Application Error", MessageBoxButtons::AbortRetryIgnore, MessageBoxIcon::Stop );
8181
}

docs/snippets/cpp/VS_Snippets_Winforms/ComboBox/CPP/comboboxcomplex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public ref class Win32Form1: public System::Windows::Forms::Form
7373
this->label2->Location = System::Drawing::Point( 0, 40 );
7474
this->label2->Size = System::Drawing::Size( 48, 24 );
7575
this->label2->TabIndex = 7;
76-
this->label2->Text = "Sring 1";
76+
this->label2->Text = "String 1";
7777
this->label2->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
7878
this->label3->Location = System::Drawing::Point( 0, 72 );
7979
this->label3->Size = System::Drawing::Size( 48, 23 );

docs/snippets/cpp/VS_Snippets_Winforms/Control_StyleChanged/CPP/control_stylechanged.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public ref class MyForm: public Form
8686
// Handle the 'StyleChanged' event for the 'Form'.
8787
void MyForm_StyleChanged( Object^ /*sender*/, EventArgs^ /*e*/ )
8888
{
89-
MessageBox::Show( "The style releated to the 'Form' has been changed" );
89+
MessageBox::Show( "The style related to the 'Form' has been changed" );
9090
}
9191
// </Snippet1>
9292
};

docs/snippets/cpp/VS_Snippets_Winforms/DataGridTableStyle_Header_4/CPP/datagridtablestyle_header_4.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/*
55
The following program demonstrates the usage of properties 'HeaderBackColor',
66
'HeaderForeColor' and events 'HeaderBackColorChanged', 'HeaderForeColorChanged'.
7-
A table is created and added to a datagrid with two coloumns.The table allows to change
7+
A table is created and added to a datagrid with two columns.The table allows to change
88
Header's background and foreground colors through selection of combobox values.
99
*/
1010

docs/snippets/cpp/VS_Snippets_Winforms/DataGridTableStyle_ResetBackColor/CPP/datagridtablestyle_resetbackcolor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public ref class MyForm: public Form
4343

4444
private:
4545

46-
// Initialilze form and its controls.
46+
// Initialize form and its controls.
4747
void InitializeComponent()
4848
{
4949
myDataGrid = gcnew DataGrid;

docs/snippets/cpp/VS_Snippets_Winforms/IDesignerExample/CPP/testcontrol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public ref class ExampleIDesigner: public System::ComponentModel::Design::IDesig
4141
this->component = component;
4242
}
4343

44-
// This method peforms the 'default' action for the designer. The default action
44+
// This method performs the 'default' action for the designer. The default action
4545
// for a basic IDesigner implementation is invoked when the designer's component
4646
// is double-clicked. By default, a component associated with a basic IDesigner
4747
// implementation is displayed in the design-mode component tray.

0 commit comments

Comments
 (0)