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:

  1. An ineffective and poor coding.
  2. Referring to any 3rd Party Library.
  3. Remote Service that take more respond time.
  4. Writing complex calculations that takes away too much of CPU’s time and capacity .

Profiling in Visual Studio

When you profile a Windows Store app that is written in JavaScript and HTML 5, you collect instrumentation data for the JavaScript code. When you profile a Windows Store app or component that is written in Visual C++, Visual C#, or Visual Basic, you collect sampling data for the native and managed code. You can profile your app locally or on a remote machine.

Some Profiling techniques

 

  1. Sampling
    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).
  2. Instrumentation
    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.
  3. 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.
  4. .NET Memory Profiling
    This profiling method collects detailed information about memory allocation and garbage collection.
  5. 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.

performance and diagnosing windows application

The following figure shows the Sample Profiling Report:

performance and diagnosing windows application

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.

performance and diagnosing windows application

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.

performance and diagnosing windows application

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.

performance and diagnosing windows application

Step 2: Select the project to check for the performance testing as shown in figure.

performance and diagnosing windows application

Step 3: Navigate to Debug menu and select Performance and Diagnostics as shown in following figure.

performance and diagnosing windows application

Step 4: The user can view the window as shown in figure. The user can select any of the available tools for testing. Three options are given by Visual Studio. These are CPU Sampling, Energy Consumption, XAML UI Responsiveness, HTML UI Responsiveness, JavaScript Function Timing, JavaScript Timing, and Performance.

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.

performance and diagnosing windows application

 

Step 7: After completion of the selected test, the result or the report is displayed as shown in figure.

performance and diagnosing windows application

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.