Application Performance Analysis Tool-Visual Studio profiler

Source: Internet
Author: User

There is a kind of speed called Turtle line, there is a kind of feeling called unbearable, there is a kind of desire called performance improvement, there is a kind of difficulty called the bottleneck.

 

Everyone wants their programs to run quickly, but how hard it is to improve performance is, even getting started. Which of the following is the key to performance improvement? Which segment is the bottleneck of the program running? Do you have to add a period of output before and after each function to find the function that consumes the most time? You should believe that in this information age, in this efficiency-first age, every repetitive job may be replaced automatically. Next, I will introduce you to Visual Studio profiler, a tool for analyzing application bottlenecks.

 

Since its name starts with Visual Studio, it must be related to. Yes, profiler is an analysis tool provided in Visual Studio. It is included in the analyze option in the main menu. If you do not find this option, you need to install a more powerful Visual Studio version. This tool is installed in Vs of the team series. In vs8.0 (2005), Visual Studio team edition has this tool. In vs9.0 (2008), Visual Studio team system developmentedition
This tool is provided with Visual Studio team suite, and ultimate is provided with this tool in vs2010.

 

Profiler is powerful. You can use it to analyze a binary file. You can use it to analyze a project or a website. Whether it is C #, VC or VB, it can be well analyzed.

 

You can use profiler to do a lot of things on a target. The most important part is the analysis of the function execution time. profiler gives the function execution time, number of executions, and the percentage of execution time in the whole program, he can provide a call tree so that you can view in profiler how the program is called step by step. You can also view the execution percentage of these functions. You can easily find the most time-consuming function. The bottleneck is the small function that you may not see. Thanks to profiler, You can optimize your program for a specific purpose.

 

After optimization, you have to look at the effect, so use profiler for analysis. What then? Profiler provides the result comparison function, which is very good and powerful. You can use this function to see which functions have improved the execution efficiency and reduced the execution efficiency of your program. Very convenient.

 

Effective analysis is the biggest feature of profiler. Therefore, profiler provides two analysis modes: Sampling and instrument.

 

Sampling is sampling. You can pause the program while running the program, record the information in the stack, and restore the program to analyze the program. Do not check that it will suspend the program. The speed of the pause, record, and recovery is very fast, which is negligible relative to the execution time of the program. Therefore, this mode has a relatively small impact on program execution. However, due to the sampling interval, some small functions that execute quickly may be ignored. However, for performance improvement, those fast functions have no analytical value. In addition, because the sampling time is the system time, it will be affected by other programs in the analysis process. For example, if you open a virtual machine during the analysis process, the function that was executed during that time may carry a black box of slow running. Therefore, instrument is required for accurate analysis.

 

Oh my God, the execution process of instrument is super slow, much slower than the speed of the software turtle line, so slow, what did you do? Before running the program, it invades the program and embeds macros for analysis at the beginning and end of each function. Record macro-transmitted information during function execution. The Analysis of instrument takes two sets of time. The actual execution time of a set of functions, like sampling, is called application time. The other is the time unit provided by Profiler, the CPU usage time of the function is calculated based on the CPU time slice executed by the program, which is called elapsed time. You can view the execution time according to your needs, because the elapsed
Time, you will have enough evidence to prove the culprit of the slow speed of the software. With such evidence, how can you fear the slow speed of analysis.

 

After the analysis of the program execution process is complete, profiler processes a large amount of data that has just been obtained, calculates the execution time of the function, the number of calls, and the mutual call relationship between functions. Finally, a report is generated. You have the right to select the report view mode. You can select summary, call tree, modules, caller/callee, functions, marks, and other modes to view the analysis results.

 

Sometimes you will find that the data processing in the future is so slow? There are two reasons: first, there is too much content to be analyzed, and the program is too large. For the sake of better running of this huge software, let's endure it. Have a cup of tea, have a meal, and check the results again, another possibility is that you have analyzed too much data that you do not need to analyze. As a part of Visual Studio, profiler certainly provides user-friendly options: launch with Profiler paused. This option allows you to ignore the program opening process that you do not want to analyze. Until you need to analyze, resume, and pause when you don't need it. Why are these options available? Because time is spent on cutting edge ......

 

In addition, Will vs be switched off after analysis? Certainly not. In general, you certainly want to keep a backup of the analysis results. But it's chilling to see the generated VSP file (vsprofiler), hundreds of MB or even G. So vs profiler provides another user-friendly option: Save analyzed. Where is this option? According to the principle of visual programming, right-click the analysis result (report. The saved result is a VSPs file (you can think about the suffix by yourself ). If you are too big, you can use export. Exported to CSV or XML files. Although they do not have such rich result viewing modes, they should be sufficient as creden。 for performance improvement.

 

I suddenly found that too many profiler statements were written, but I briefly introduced a common profiler function, how to use it, and which of the following small functions are some simple problems, you can explore it on your own. Of course, I suggest you start your profiler journey from the next article: Find application bottlenecks with Visual Studio profiler, http://msdn.microsoft.com/en-us/magazine/cc337887.aspxthis is Microsoft msdnw.visual
Studio profiler. From the software development status to profiler introduction to profiler use instances. Images and texts are illustrated, and it also has a Chinese translation version: Movie.

Related Article

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.