Use visual Studio to find app performance bottlenecks

Source: Internet
Author: User

Use visual Studio to find app performance bottlenecks

Last updated on : 2014-05-05

Read the Prerequisites :

Environment : Windows 8.1 64bit in English, Visual Studio 2013 professional Update1 English version

Body

If performance optimizations are taken into account throughout the development of the application, the development efficiency will be low, so we need to analyze the existing code with the Profiler tool, where is the bottleneck of performance? Then optimized for hotspots, which can improve the input-to-output ratio of the product, the Visual Studio 2013 Professional profile tool has four features, the normal C + + program uses only [CPU sampling] and [instrument] two features, where [CPU Sampling] is a recommended option for analyzing the performance of C + + programs.

For example, in the C + + language Windows Console project that takes a few seconds to run, select the main Menu [Analyze]->[performance and Diagnostics] to open the [Performancewizard] window with four options, Select CPU sampling (recommended), measure the call time of the function, the wizard has three steps, finally click [Finish] to start the Profiling until the end of the program execution, the profile tool generated sample Profiling report.

Hot Path column,

Elapsedinclusive time, Function takes

Elapsed Exclusive time, which is the inclusive times minus the runtime of the child function

If you want to know the number of detailed calls for each function you can select [instrumentation] in [Performance Wizard], because it will insert the measurement code before and after each function, so it takes a long time to run the program and analyze the report. The instrumentation Profiling report is generated at the end and is not recommended as compared to the sample profilingreport, which is more information about the number of function calls.

How do I find the most time-spent function?

Summary view, Functionswith Most individual the work bar lists the most time-consuming five functions, directly click on the function name in the list, switch to [function Details]view, below is the Initsample function [ Functiondetails] View screenshot:


Three tiles represent [1] the caller [2] The current function [3] The callee, the dark blue background above shows the percentage of time that includes the child function call (Inclusive times), and the light blue display function body (excluding child functions) of the percentage of time (Exclusive). Click [Caller/callee] below to go to the [Caller/callee] view, through the caller and callee list, see the number of calls to each function, and the percentage of time spent.

You can switch to the [Functions] view to see all the functions, and let them sort by how much time it takes to find the most time-consuming function you want.

Search for a specified function by name

Switch to functions (or modules) view, [ctrl]+[f] shortcut popup Find window enter the name of the function you are looking for, specify the search range as [current Document], press [Enter] to find the function, double-click the function name to switch to the function's [Function Details] view. To find a function of a module, it is best to find a function under a Modules in this view under the [Modules] view.

Find the specified function based on the number of calls

In the [Functions] view, you can click on a column name, and the function list will be sorted by the size value of the property of the column, and the function Details view can be switched to the function after it is found.

Find by Function call order

How do you know the approximate location of the hotspot, switch to the [call Tree] View, find the root node, right-click the pop-up menu to select [Set Root], so that you can not look at other branches, if you want to reset the root node, the pop-up menu to select [Reset Root].

According to number Ofcalls (call count) and elapsed tiime (time cost) step-by-step expansion of the node until the function to be modified, right-click popup menu selection [View source] can go to the specific source code, [Show Function Details] When you switch to the [functiondetails] view of the current function, the upper-right corner of the blue box shows the percentage of the total time of the current function (Inclusive times), and the blue box can be left-clicked to switch to the function Details view of the specified functions. Click on the Caller/callee below the three box to see a more detailed caller, callee information.

How to analyze a program that runs for a long time

When profile is running, you can choose [stopprofiling] to end the analysis and generate instrumentation (or sampling) Profiling report, which appears by default in summary view.

Refer to the Summary view, mark the time period you want to analyze on the graph, right-click the popup menu, and select the [Filter Profiling Data by Selection] item.

Resources

"Find application bottlenecks with Visual Studio Profiler"

Http://msdn.microsoft.com/en-us/magazine/cc337887.aspx

Use visual Studio to find app performance bottlenecks

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.