ANTS Performance Profiler (. NET Performance Tuning tutorial)

Source: Internet
Author: User





. NET Performance Tuning series articles



Series Article Index


    • . NET Performance tuning: Use of the ANTS performance Profiler

    • . NET Performance Tuning two: Code metrics with Visual Studio

    • . NET Performance Tuning three: tuning tools and methods for YSlow related rules


In use. NET to quickly get started and develop applications, the next problem may be the program performance tuning problems, and performance tuning sometimes involves a lot of problems, such as the program hosting system, database, network environment and so on, and when the program is unusually large and complex, performance tuning will become more difficult.



This series of articles will mainly introduce some. NET performance tuning tools, Web performance tuning rules (such as YSlow), methods, and more. The last thing I want to see in the paper is the uninterrupted "which language is good, which language performance is high" in the garden, not to say, the real sensible understand the argument has no meaning, hope we can from the actual performance optimization point of view to discuss the problem.



Basic use of ANTS performance Profiler



ANTS Performance Profiler is Redgate's powerful performance tuning product, the official product page here.



First look at the basic use of software.



Use the following code for a simple test.



This is a console application, the program is very simple, first 10,000 cycles, output and, then use LINQ in the list to find out the value of 1000 output.



1 static void Main() 

2 { 

3 var list = new List<int>(); 4 5 var sum = 0; 6 for (var i = 0; i < 10000; i++) 7 { 8 sum += i; 9 list.Add(i);10 }11 Console.WriteLine(sum);12 13 //find the value use linq: 100014 var result = list.Where(p => p.Equals(1000));15 foreach (var i in result)16 {17 Console.WriteLine(i);18 }19 Console.ReadKey();20 }

 


After compiling the program, launch ants performance Profiler, the wizard page will automatically pop up, on this page, you can see the software support a variety of. NET program performance monitoring, such as EXE, Web, Windows service, and so on.



In performace counters, you can select multiple counters, IO, memory allocations, processors, and so on, as needed.



For the test demo, select the compiled exe file path, because it was Debug compiled, so choose the program folder under the \bin\debug\ EXE can be.



In profiling mode, you can choose the level of monitoring, basically is to monitor the amount of information and speed trade-offs, the default choice of "most detailed". Additional detailed settings can be found in the Help documentation.



Click "Start Profiling" to start the program.






Review and analysis of analysis results



The basic working principle of software is in the. NET compiled IL code put hooks to record time, and then through the intuitive interface to show which part of the code to consume the most energy. So this is the most straightforward approach to performance tuning, optimized for the most time-consuming code snippets.



Click "Start Profiling" after the start of the compiled program, the software began to execute , if it is other interactive programs such as WinForm, the web, etc., after the operation needs to perform the performance tuning function, At the top of the run time axis with the mouse to select the time period you want to see, the general performance problem of the time period will appear a crest, select that time period.






When selected, you can immediately see the most time-consuming method in the results window below, such as the demo above, and of course the performance is consumed on the main function.






The software provides a variety of metrics to view performance losses, percentages and multiple time formats, where "seconds" is selected as the unit of measure.






Then select the function you want to see, and the software is powerful.


    • On the right side of the red line, click can quickly locate the most energy-consuming code, the darker the color of the code the more energy.

    • On the left you can see the line number, the number of times the code executes (hit Count), the average execution time, the total execution time, and of course the code to be used for analysis.


As for why this code first executes Console.WriteLine so energy, I think if you read the first chapter of the CLR via C # You should be able to know the answer.






Of course you can also click on the hierarchy icon to see more intuitive performance loss, just like the following.



One benefit of such a hierarchy chart is that you can see the internal implementation of the. NET Framework.



This can be useful when making decisions, such as using native functionality or third-party components, because it gives you a more intuitive view of where internal implementation performance bottlenecks are.






Conclusion



ANTS Performance Profiler is my first use of performance tuning is also the most like to use the tool, so put in the first article to share to everyone, hope to bring you a little help.



It is very intuitive, powerful, because the complex project at hand is not suitable for the demo, so just write a simple piece of code for the demonstration, and its strength is still to you when you really encounter performance problems to use it to feel good.



Articles are omitted and to be supplemented, please leave a message to discuss together, please also follow the relevant articles.



If the article is a little help to you, recommend it, thank you:)


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.