|
1 | 1 | --- |
2 | | -title: The Sampling Feature |
3 | | -weight: 3 |
| 2 | +title: Use the sampling feature |
| 3 | +weight: 4 |
4 | 4 |
|
5 | 5 | ### FIXED, DO NOT MODIFY |
6 | 6 | layout: learningpathall |
7 | 7 | --- |
8 | 8 |
|
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. |
10 | 10 |
|
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? |
12 | 12 |
|
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. |
14 | 14 |
|
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? |
18 | 16 |
|
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. |
20 | 18 |
|
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: |
24 | 20 |
|
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 |
26 | 25 |
|
27 | | -1. **Filling in Necessary Fields**: |
| 26 | +Fill in these fields with the information you want to sample. |
28 | 27 |
|
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. |
35 | 29 |
|
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`. |
46 | 31 |
|
47 | 32 |  |
48 | | -_Sampling overview UI_ |
49 | 33 |
|
50 | | -## Initiating the Sampling Process |
| 34 | +## How do I initiate sampling? |
51 | 35 |
|
52 | | -1. **Starting the Sampling**: |
| 36 | +To start the sampling click on the play button. |
53 | 37 |
|
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. |
55 | 39 |
|
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. |
57 | 41 |
|
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? |
59 | 43 |
|
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. |
61 | 45 |
|
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. |
63 | 47 |
|
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. |
65 | 49 |
|
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? |
67 | 51 |
|
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 | | - |
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. |
77 | 53 |
|
78 | 54 |  |
79 | | -_Sampling results shown in the code editor_ |
80 | 55 |
|
81 | | -## Re-evaluating Post Edits |
| 56 | +## How do I evaluate the result after making changes? |
82 | 57 |
|
83 | | -1. **Comparing Results**: |
| 58 | +After you make code changes run the sampling process again. |
84 | 59 |
|
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. |
86 | 61 |
|
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. |
88 | 63 |
|
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? |
90 | 65 |
|
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. |
92 | 67 |
|
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. |
94 | 69 |
|
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: |
96 | 71 |
|
97 | | -```shell |
| 72 | +```output |
98 | 73 | warning: other WindowsPerf process acquired the WindowsPerf-driver. |
99 | 74 | Operation canceled! |
100 | 75 | ``` |
101 | 76 |
|
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. |
103 | 80 |
|
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: |
105 | 82 |
|
106 | | -```shell |
| 83 | +```output |
107 | 84 | warning: other WindowsPerf process hijacked (forced lock) the wperf-driver, see --force-lock. |
108 | 85 | Operation terminated, your data was lost! |
109 | 86 |
|
|
0 commit comments