Skip to content

Commit cdead2c

Browse files
Merge pull request #1604 from jasonrandrews/review
Review Visual Studio extension for WindowsPerf Learning Path
2 parents 416e8fc + 5ea5674 commit cdead2c

File tree

8 files changed

+165
-130
lines changed

8 files changed

+165
-130
lines changed

content/learning-paths/laptops-and-desktops/windowsperf-vs-extension/_index.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: WindowsPerf Visual Studio extension
2+
title: Learn how to use the Visual Studio extension for WindowsPerf
33
draft: true
44
cascade:
55
draft: true
@@ -13,15 +13,13 @@ learning_objectives:
1313
- Generate a counting report and explore the data.
1414
- Review the report in Windows Performance Analyzer (WPA).
1515
- Generate a sample report and explore the data.
16-
- Generate a sample SPE report and explore the data.
1716

1817
prerequisites:
1918
- A desktop or laptop running Windows on Arm.
2019
- Visual Studio 2022 Community Edition, WindowsPerf, WindowsPerf Visual Studio extension, and Windows Performance Analyzer (WPA) installed.
2120

2221
author:
2322
- Nader Zouaoui
24-
- Jason Andrews
2523

2624
### Tags
2725
skilllevels: Introductory
Lines changed: 26 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,53 @@
11
---
2-
title: The Counting Feature
3-
weight: 2
2+
title: Use the counting feature
3+
weight: 3
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## Introduction
9+
The Counting feature in the Visual Studio extension for WindowsPerf is a powerful tool for analyzing and optimizing your code's performance.
1010

11-
- WindowsPerf installed [(Installation guide)](/install-guides/wperf/)
12-
- Visual Studio 2022 Community Edition installed [(Installation guide)](/install-guides/vs-woa/)
13-
- WindowsPerf Visual Studio extension installed [(Installation guide)](/install-guides/windows-perf-vs-extension/)
14-
- (Optional) WindowsPerf WPA plugin installed
15-
16-
17-
The Counting feature in the WindowsPerf GUI extension is a powerful tool for analyzing and optimizing your code's performance.
18-
This tutorial guides you through the entire process, from setting up your counting preferences to analyzing the results and interfacing with the WindowsPerf Windows
11+
This section guides you through the entire process, from setting up your counting preferences to analyzing the results and interfacing with the WindowsPerf Windows
1912
Performance Analyzer (WPA) Plugin.
2013

21-
## How to Open Counting Settings
22-
23-
**Accessing Counting Settings**:
24-
25-
- In Visual Studio 2022, go to the `View` menu.
26-
- Select `Counting Settings` from the dropdown.
27-
- This action will open the Counting Settings Dialog.
28-
29-
## Configuring the Counting Parameters
30-
31-
1. **Filling in Necessary Fields**:
14+
## How do I access the counting settings?
3215

33-
- The dialog presents multiple fields for configuration. Essential fields to fill in include:
34-
- CPU core selection
35-
> Note: if no target is selected, the CPU core selection allows for multiple
36-
> cores to be selected.
37-
- Event or Metric choice
38-
> Note: Events can be grouped by selecting the events to group, then clicking on
39-
> the `Group events` button.
40-
- Fill these in according to the specifics of the counting you wish to perform.
16+
Open the `View` menu in Visual Studio 2022 and select `Counting Settings` from the dropdown. This opens the `Counting Settings` dialog.
4117

42-
2. **Optional Parameters**:
18+
## How do I configure the counting parameters?
4319

44-
- You can also set other parameters as per your requirements.
20+
The counting settings dialog presents multiple fields for configuration.
4521

46-
3. **Command Preview**:
22+
Essential fields to fill in include:
4723

48-
- As you configure the settings, the dialog provides a real-time preview of the
49-
WindowsPerf command that will be executed.
24+
- CPU core selection: you can select a subset of the CPU cores or all of them.
25+
- Event List and Metric List: you can select events such as `cpu_cycles` and metrics such as `dcache`.
5026

51-
4. **Timeline Parameters**:
27+
{{% notice Note %}}
28+
Events can be grouped by selecting the events to group, then clicking on the `Group events` button.
29+
{{% /notice %}}
5230

53-
The option to create a timeline is available by toggling the `Timeline` checkbox.
54-
You then have the option to:
31+
You can also set other parameters as per your requirements.
5532

56-
- Choose the number of iterations to run the timeline (defaults to 1).
57-
- Choose the interval between each iteration (defaults to 0.5 second).
33+
As you configure the settings, the dialog provides the `WindowsPerf command preview`. This the command that will be executed.
34+
35+
Check the `Timeline` check box create a timeline view. Choose the number of iterations to run the timeline (defaults to 1) and the interval between each iteration (defaults to 0.5 second).
5836

59-
## Initiating the Counting Process
37+
## How do I initiate counting?
6038

61-
1. **Starting the Counting Process**:
39+
To start the counting process click on the `Start` button.
6240

63-
- Click on the `Start` button to kickstart the sampling.
64-
65-
> Note: The `Build and start` button is also available to build the solution
66-
> before starting the counting process if the current project target is selected.
67-
68-
- If you’ve set a timeout, the process will run for the specified duration.
69-
Otherwise, you have the flexibility to end the counting manually using the `Stop` button.
70-
71-
- The `Stop` button can also be used to interrupt the process even if the timeout
72-
hasn’t lapsed and the collected counts will be shown in the table below.
41+
If you’ve set a timeout, the process will run for the specified duration. Otherwise, you have the flexibility to end the counting manually using the `Stop` button.
42+
43+
For the current code example, you will see the counted events in the `Counting Output` located in the lower section of the dialog.
7344

7445
![Start Counting](./start-counting.png)
75-
_Counting Settings UI_
76-
77-
## Delving into the Counting Results
78-
79-
1. **Analyzing the Results**:
8046

81-
- Post-counting, you’ll notice the table in the `Counting Output` located at the
82-
lower section of the Counting Settings dialog displaying the collected counts.
47+
## How can I analyze the results?
8348

84-
(**Optional**)
49+
You can click the `Open in WPA` button to open the collected counts in the Windows Performance Analyzer (WPA). The WindowsPerf WPA Plugin provides in-depth visualization and analysis of the results.
8550

86-
- The option to **Open in WPA** is available to open the collected counts in the
87-
Windows Performance Analyzer (WPA) using the WindowsPerf WPA Plugin for a more
88-
in-depth visualization and analysis of the results.
51+
A screenshot of WPA is below:
8952

9053
![Open in WPA #center](./open-in-wpa.png)
91-
_WPA UI_
21.2 KB
Loading
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: Configure your development tools
3+
weight: 2
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Which development tools do I need to use WindowsPerf with Visual Studio?
10+
11+
Four development tools are recommended if you want to use WindowsPerf for performance analysis on a Windows on Arm computer.
12+
13+
Each tool has an install guide explaining how to install and configure it.
14+
15+
Use the install guides to install and configure each tool before getting started:
16+
17+
- [Visual Studio 2022 Community Edition](/install-guides/vs-woa/)
18+
- [WindowsPerf](/install-guides/wperf/)
19+
- [Visual Studio extension for WindowsPerf](/install-guides/windows-perf-vs-extension/)
20+
- [Windows Performance Analyzer (WPA) plugin](/install-guides/windows-perf-wpa-plugin/)
21+
22+
23+
## How can I try out the WindowsPerf features in Visual Studio?
24+
25+
You can use the code example below to demonstrate WindowsPerf features in Visual Studio.
26+
27+
Create a new C++ Console App named `App1` in Visual Studio.
28+
29+
Remove the provided code and replace it with the code below:
30+
31+
```C++
32+
#include <iostream>
33+
#include <vector>
34+
#include <chrono>
35+
36+
const int N = 10000; // Matrix size
37+
38+
void fillRowWise(std::vector<std::vector<int>>& matrix) {
39+
for (int i = 0; i < N; ++i) {
40+
for (int j = 0; j < N; ++j) {
41+
matrix[i][j] = i + j;
42+
}
43+
}
44+
}
45+
46+
void fillColumnWise(std::vector<std::vector<int>>& matrix) {
47+
for (int j = 0; j < N; ++j) {
48+
for (int i = 0; i < N; ++i) {
49+
matrix[i][j] = i + j;
50+
}
51+
}
52+
}
53+
54+
int main() {
55+
std::vector<std::vector<int>> matrix(N, std::vector<int>(N, 0));
56+
57+
// Measure row-wise traversal
58+
auto start = std::chrono::high_resolution_clock::now();
59+
fillRowWise(matrix);
60+
auto end = std::chrono::high_resolution_clock::now();
61+
std::cout << "Row-wise fill time: "
62+
<< std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
63+
<< " ms" << std::endl;
64+
65+
// Measure column-wise traversal
66+
start = std::chrono::high_resolution_clock::now();
67+
fillColumnWise(matrix);
68+
end = std::chrono::high_resolution_clock::now();
69+
std::cout << "Column-wise fill time: "
70+
<< std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
71+
<< " ms" << std::endl;
72+
73+
return 0;
74+
}
75+
```
76+
77+
The example code shows the difference between filling a matrix in a different order. You will see that column-wise traversal is much slower than row-wise traversal. This happens because:
78+
- Row-wise access follows how memory is stored in contiguous blocks.
79+
- Column-wise access jumps across rows, causing frequent cache misses.
80+
81+
On the `Build` menu select `Build Solution` to generate `App1.exe`.
82+
83+
Run the program by opening the `Debug` menu and select `Start Without Debugging`.
84+
85+
This will run the debug build for the program.
86+
87+
The console output is shown below:
88+
89+
![Run Debug](./debug.png)
90+
91+
Change the Visual Studio target to `Release` instead of `Debug` and build the solution again.
92+
93+
The console output shows shorter execution time due to compiler optimizations.
94+
95+
Here is the new output:
96+
97+
![Run Release](./release.png)
20.7 KB
Loading

content/learning-paths/laptops-and-desktops/windowsperf-vs-extension/sampling-feature.md

Lines changed: 39 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,86 @@
11
---
2-
title: The Sampling Feature
3-
weight: 3
2+
title: Use the sampling feature
3+
weight: 4
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## Introduction
9+
The Sampling feature in the Visual Studio extension for WindowsPerf is a powerful tool for analyzing and optimizing your code's performance. This section guides you through the entire process, from setting up your sampling preferences to analyzing the results and implementing changes.
1010

11-
The Sampling feature in the WindowsPerf GUI extension is a powerful tool for analyzing and optimizing your code's performance. This tutorial guides you through the entire process, from setting up your sampling preferences to analyzing the results and implementing changes.
11+
## How do I open the sampling explorer?
1212

13-
## How to Open Sampling Explorer
13+
Open the `View` menu in Visual Studio 2022 and select `Sampling Explorer` from the dropdown. This opens the `Sampling Explorer` dialog.
1414

15-
1. **Accessing Sampling Explorer**:
16-
- In Visual Studio 2022, go to the `View` menu.
17-
- Select `Sampling Explorer` from the dropdown.
15+
## How do I configure the sampling preferences?
1816

19-
## Setting Your Sampling Preferences
17+
From the `Sampling Explorer` window, find and click on the `Configure the sampling command` icon, it looks like a gear. This action will open the `Sampling Settings` dialog.
2018

21-
1. **Opening Sampling Settings**:
22-
- Inside the Sampling Explorer window, find and click on the `settings wheel` icon.
23-
- This action will open the Sampling Settings Dialog.
19+
Fill in the required fields listed below:
2420

25-
## Configuring the Sampling Parameters
21+
- File payload: file to profile
22+
- CPU core selection: cores to sample
23+
- Event choice: available events
24+
- Desired frequency: sampling frequency
2625

27-
1. **Filling in Necessary Fields**:
26+
Fill in these fields with the information you want to sample.
2827

29-
- The dialog presents multiple fields for configuration. Essential fields to fill in include:
30-
- File payload
31-
- CPU core selection
32-
- Event choice
33-
- Desired frequency
34-
- Fill these in according to the specifics of the sampling you wish to perform.
28+
As you configure the settings, the dialog provides a real-time preview of the WindowsPerf command that will be executed in the `WindowsPerf Command Preview` box.
3529

36-
2. **Optional Parameters**:
37-
38-
- You can also set other parameters as per your requirements.
39-
40-
3. **Command Preview**:
41-
42-
- As you configure the settings, the dialog provides a real-time preview of the WindowsPerf command that will be executed.
43-
44-
4. **Saving Your Settings**:
45-
- Once you are satisfied with your configurations, click `save`.
30+
When you are satisfied with your configurations, click `Save`.
4631

4732
![Sampling overview #center](./sampling-overview.png)
48-
_Sampling overview UI_
4933

50-
## Initiating the Sampling Process
34+
## How do I initiate sampling?
5135

52-
1. **Starting the Sampling**:
36+
To start the sampling click on the play button.
5337

54-
- Click on the play button to kickstart the sampling.
38+
If you have set a timeout, the process will run for the specified duration. Otherwise, you have the flexibility to end the sampling manually using the stop button.
5539

56-
- If you’ve set a timeout, the process will run for the specified duration. Otherwise, you have the flexibility to end the sampling manually using the stop button.
40+
The stop button can also be used to interrupt the process even if the timeout hasn’t lapsed and the collected samples will be shown in the next screen.
5741

58-
- The stop button can also be used to interrupt the process even if the timeout hasn’t lapsed and the collected samples will be shown in the next screen.
42+
## How do I view the sampling results?
5943

60-
## Delving into the Sampling Results
44+
When the sampling stops, you notice the window divides into two sections: a tree view and a detailed analysis section.
6145

62-
1. **Analyzing the Results**:
46+
Navigate through the tree view by clicking on the nodes. This reveals functions triggered, selected events, line numbers in the source code, and the responsible source files.
6347

64-
- Post-sampling, you’ll notice the window divides into two sections: a tree view and a detailed analysis section.
48+
Any accessible source file appears as a clickable hyperlink. Selecting it will directly open the file within the Visual Studio IDE.
6549

66-
- Navigate through the tree view by clicking on the nodes. This will reveal functions triggered, selected events, line numbers in the source code, and the responsible source files.
50+
## How do I implement code changes?
6751

68-
- An added convenience: Any accessible source file appears as a clickable hyperlink. Selecting it will directly open the file within the IDE.
69-
70-
## Implementing Code Adjustments
71-
72-
![Sampling settings #center](./sampling-settings.png)
73-
_Sampling settings UI_
74-
75-
1. **Optimizing Your Code**:
76-
- Based on the insights gathered from the sampling results, proceed to make any required optimizations or edits to your source code.
52+
Based on the insights gathered from the sampling results, proceed to make any required optimizations or edits to your source code.
7753

7854
![Sampling results #center](./sampling-results.png)
79-
_Sampling results shown in the code editor_
8055

81-
## Re-evaluating Post Edits
56+
## How do I evaluate the result after making changes?
8257

83-
1. **Comparing Results**:
58+
After you make code changes run the sampling process again.
8459

85-
- Post editing, run the sampling process again.
60+
This allows you to instantly compare and contrast the results before and after your code modifications, ensuring optimal performance improvements.
8661

87-
- This allows you to instantly compare and contrast the results before and after your code modifications, ensuring optimal performance improvements.
62+
With these steps, you are well-equipped to make use of the sampling feature in the Visual Studio extension for WindowsPerf and improve code performance.
8863

89-
- With these steps, you are well-equipped to make the best of the sampling feature in the WindowsPerf GUI extension. Happy coding and optimizing!
64+
## What does lock and unlock for WindowsPerf and the kernel driver?
9065

91-
## Lock Unlock
66+
When WindowsPerf communicates with the Kernel Driver, the driver acquires a lock and will deny access to other instances of WindowsPerf accessing the driver.
9267

93-
When WindowsPerf communicates with its Kernel Driver, the driver acquires lock and will deny access to other instances of WindowsPerf accessing the driver and its resources. This prevents others from interfering with the current WindowsPerf execution and protects you from interference with your count.
68+
This prevents others from interfering with the current WindowsPerf execution and protects you from interference with your counting.
9469

95-
When another WindowsPerf process has locked access to the driver you will no longer be able to use WindowsPerf, you will instead receive the following error message:
70+
When another WindowsPerf process has locked access to the driver you will no longer be able to use WindowsPerf, you will instead receive the following error message:
9671

97-
```shell
72+
```output
9873
warning: other WindowsPerf process acquired the WindowsPerf-driver.
9974
Operation canceled!
10075
```
10176

102-
In order to force the release of the lock, a new --force-lock command argument was introduced to both WindowsPerf and the extension that lets you interrupt the ongoing WindowsPerf process and take over the lock.
77+
In order to force the release of the lock, a new --force-lock command argument is available for both WindowsPerf and the Visual Studio extension that allows you to interrupt the ongoing WindowsPerf process and take over the lock.
78+
79+
However, interrupting a running `wperf` process results in loss of collected data.
10380

104-
However, interrupting a running wperf process would result in losing all the collected data. If interrupted, WidowsPerf will show the following error message:
81+
If interrupted, WidowsPerf will show the following error message:
10582

106-
```shell
83+
```output
10784
warning: other WindowsPerf process hijacked (forced lock) the wperf-driver, see --force-lock.
10885
Operation terminated, your data was lost!
10986

content/learning-paths/laptops-and-desktops/windowsperf-vs-extension/spe-feature.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: The SPE Feature
3-
weight: 4
3+
weight: 5
4+
draft: true
45

56
### FIXED, DO NOT MODIFY
67
layout: learningpathall
-466 KB
Loading

0 commit comments

Comments
 (0)