Before we proceed towards exploring Diagnosing and Performance tool in Visual Studio we must know the reasons due to which our app can give a poor performance. Some of the reasons can be:
- An ineffective and poor coding.
- Referring to any 3rd Party Library.
- Remote Service that take more respond time.
- Writing complex calculations that takes away too much of CPU’s time and capacity .
Profiling in Visual Studio
Some Profiling techniques
Sampling is the only option available in Windows Store app, with some limitations (some sampling options, such as setting the sampling event and timing interval, or collecting additional performance counter data does not supported for Windows Store apps).
Instrumentation profiler, on the other hand, follows a more invasive approach because it injects specific tracing code at the beginning and end of the each function. This tracing code enables the profiling tool to record each time the execution flow enters and exits an instrumented function.
- Concurrency Profiling
This profiling method collects detailed information from the call stack each time while the competing threads forced to wait for access to a shared resource. It also provides useful information about how an application interacts with the overall environment, enabling the user to identify performance bottlenecks, synchronization issues, and so on.
- .NET Memory Profiling
This profiling method collects detailed information about memory allocation and garbage collection.
- Tier Interaction Profiling (TIP)
This profiling method collects information about ADO.NET function that calls to a SQL Server database.
How to Profile Performance
The user can test the app performance at runtime. If the performance of the app is good, then, it is ready for sale in the market. Users like only those apps that deliver better performance and speed.
To test the performance, the user has to navigate to Debug -> Performance and Diagnosis. Then, the Performance wizard will open as shown in figure.
The following figure shows the Sample Profiling Report:
How to profile Memory Usage
While developing the app, the user can check the memory load. Memory will increase in size whenever more resource files are used. Resource includes images, style sheets, scripts, third party DLLs, and many more. The developer can track the memory usage when the app is running.
Right-click the Taskbar and select Task Manager from the Context Menu as shown in figure.
When the Task Manager is opened, the user can view the memory usage of the app as shown in figure. Depending upon the size, the app will be faster, and reliable. It shows the Task Manager window that shows the details of memory allocated for the app as shown in the following figure.
Using a Performance and Diagnostics Tool
In order to use the performance and diagnostic tools, perform the following steps:
Step 1: Open the project on which the Performance Test is to be performed. Select Open Project from the start page. Figure shows the Start page to open a New Project.
Step 2: Select the project to check for the performance testing as shown in figure.
Step 3: Navigate to Debug menu and select Performance and Diagnostics as shown in following figure.
Step 5: This example will show how to process CPU Sampling. To test the CPU sampling, the user has to select CPU Sampling from the Available Tools as shown in figure. Click the Start button to start the testing.
Step 7: After completion of the selected test, the result or the report is displayed as shown in figure.
Step 10: To export the report, the user should click the Export Report Data from the Report tab.
Step 11: While exporting the report, the user can select the details that are to be exported in the report by marking or checking various options as shown in figure. The options are Caller, Call Tree, Functions, Header, and so on. The exported reports in Excel format are saved in the project folder.