Using the Sampling method in Visual Studio to collect performance statistics

When you start sampling on your application, it collects information about the methods that are executing in the application flow and provides a summary as a result. Methods that are heavily executed during the execution cycle become part of the active function call tree known as Hot Path. Once the test is completed, it generates the timeline graph that you can use to look for the bottleneck.

In Visual Studio 2015 or greater, we can start the sampling process by going to the Analyze > Performance Profiler... menu. Make sure the configuration is set to release mode.

Once you run your application, it starts recording your application flow and identifies the Hot Path. You can perform operations on your app that can produce performance issues and then stop your application and profiler:

To get the sampling profiling result, choose the CPU sampling and finish. This will run the profiler in the background and open up an application where you can perform any action and execute any scenario. Once you close your application, a profiling report will be generated.

Profiling report shows three sections that are Sample Profiling report, Hot Path, and Functions, which do most of the individual work. Sample profiling report displays the graph shows the CPU usage in a percentage at a particular time. Hot Path tells you which code path in your application is responsible for most of the CPU execution. Hot Path displays the Inclusive and Exclusive samples. Inclusive samples are collected during the execution of the target function and contain the samples of the child functions that are executed, whereas exclusive functions do not contain the child function execution and contain the direct execution of the instructions executed by the target function. We can also click on any of the functions being executed to see the code that has taken that time.

Here is Hot Path showing that 100% execution time was done on GetData method:

We can click on GetData to see the complete function call and the code being executed:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.13.164