Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of ANTS Performance Profiler

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the example analysis of ANTS Performance Profiler, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Basic use of ANTS Performance Profiler

ANTS Performance Profiler is a powerful performance tuning product under RedGate, and the official product page is here.

Let's first take a look at the basic use of the software.

Use the following code for a simple test.

This is a console application, the program is very simple, first do 10000 loops, output and, and then use LINQ to find a 1000 value output in list.

1 static void Main () 2 {3 var list = new List (); 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, start ANTS Performance Profiler, which automatically pops up the wizard page, where you can see that the software supports performance monitoring of a variety of .NET programs, such as EXE, web, Windows Service, and so on.

In Performace Counters, you can choose a variety of counters, such as IO, memory allocation, processor, and so on.

For the test DEMO, select the path to the compiled exe file, because it was compiled by debug, so select exe in\ bin\ Debug\ under the program folder.

In Profiling Mode, you can choose the level of monitoring, which is basically the tradeoff between the number of monitoring information and speed. You can choose "most detailed" by default. Other detailed settings can be found in the help documentation.

Click "Start Profiling" to start the program.

Viewing and analysis of analysis results

The basic principle of the software is to put hooks into the IL code compiled by. Net to record the time, and then show which part of the code consumes the most energy through an intuitive interface. So this is the most direct method of performance tuning, which can be optimized for the most time-consuming code segments.

Click "Start Profiling" after starting the program compiled before, the software begins to execute, if it is other interactive programs such as winform, web, etc., after the operation of the need for performance tuning functions, in the top of the running timeline with the mouse to select the time period you need to view, generally there will be a wave peak in the time period of performance problems, select that time period.

Once selected, you can immediately see the most time-consuming methods in the results window below, such as the DEMO above, of course, the performance is consumed by the Main function.

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

Then select the function you want to view, and the power of the software will be revealed.

Click on the red line on the right to quickly locate the most energy-consuming code, and the darker the color is, the more energy-consuming that code is.

On the left, you can see the line number, the number of times this code has been executed (Hit Count), the average execution time, the total execution time, and, of course, the code for analysis at the same time.

As for why this code in DEMO uses so much energy to execute Console.WriteLine for the first time, I think you should know the answer if you read the first chapter of "CLR via C #".

Of course, you can also click on the hierarchy icon to see more intuitive performance attrition, as shown below.

Another benefit of such a hierarchical diagram is that you can see the internal implementation of the .NET Framework.

This feature becomes very useful when making decisions, such as whether to use native features or third-party components, because it gives you a more intuitive view of the performance bottlenecks of the internal implementation.

Thank you for reading this article carefully. I hope the article "sample Analysis of ANTS Performance Profiler" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report