Click here to Skip to main content
Click here to Skip to main content

The Simple Profiler for .NET Developers

, 25 Nov 2004
ANTS Profiler allows you to identify slow lines of code in .NET applications within 5 minutes of installation, allowing you to get on with what you do best - writing code.

Editorial Note

This article is in the Product Showcase section for our sponsors at CodeProject. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers.

ANTS Profiler by Red Gate Software

(Click here for your free trial)

If you are involved in .NET development, you have probably become familiar with the situation of having code that sort-of-works, but is quite a long way from the ideal solution. .NET applications often run very slowly or hog system resources, even when they’ve been coded "from the book," often because more is going on behind the scenes in the .NET library than you might think.

ANTS Profiler is a profiling tool designed for .NET developers who want to get to the bottom of these and other related issues. Technical testers also use ANTS Profiler to pin bugs down to a specific line of code or to determine scope for optimization.

What ANTS Profiler does

ANTS Profiler allows you to identify slow lines of code in .NET applications within 5 minutes of installation, allowing you to get on with what you do best - writing code. The program can also be used to:

  • measure line-level and method execution times
  • understand how your application performs
  • understand how your application uses memory

Profiling an application with ANTS Profiler

ANTS Profiler will profile Windows applications, ASP.NET web applications, COM+ applications and .NET web services.  It supports applications written in VB.NET, C#, C++ (managed) and any other language supported by the .NET framework (this includes over 40 languages).

 It is the ideal tool when you’ve developed an application and you need to see if it is going to perform as expected.

The screenshots and explanation below will walk you through profiling performance and is based on a demonstration .NET desktop application, Mandelbrot.exe, that draws a fractal mathematical function called the Mandelbrot Set. 


Mandelbrot application uses two alternative methods of calculating the picture "Quick" and "Slow".

This walk-through shows how you can use ANTS Profiler to identify the most time critical parts of the application.  It will introduce you to the main features and show you how you would use ANTS Profiler to profile your own applications

The first step is to launch ANTS Profiler and use the Profiler Project Wizard to specify the type of profiling you want to perform.

ANTS Profiler Project Wizard

We select Profile performance as we want to investigate the execution time of different methods in our application and then click Next to move on to the next screen in the wizard. 

Now we need to specify the type of .NET application we want to profile. As the Mandelbrot program is a desktop application, we select .NET desktop application and click the Next button to continue.

The next step in the Profiler Project Wizard allows you to specify the application executable file so we browse to locate the file Mandelbrot.exe. The final step allows you to specify which methods to profile in your application. In this case, we select Only .NET methods that have source code. As this application is a debug build with source code, we are only interested in profiling methods with source code. After clicking Finish and exiting the wizard, we are ready to start profiling.

A dialog will appear asking you to confirm that you want to start profiling the application.  Clicking Yes will launch the application.

When you start profiling, ANTS Profiler launches your application and makes it active so you can run through those parts of your application that you want to profile. In the Mandelbrot set window we click the Slow button to choose the slow algorithm, and then click the Draw Mandelbrot Set button to draw the image.

Once the image has been drawn, we click the close box to exit the Mandelbrot.exe application. This automatically stops ANTS Profiler from profiling and shows a Summary of the results for your application. The Summary contains basic information about the application along with the 10 Slowest lines of code, 10 Slowest methods, and 10 Slowest methods with children. You can click on any of the links in the Summary to navigate to particular methods or lines of source code. When you click any of the slowest lines of code in the Summary, the Source code panel will automatically update to show the relevant source code and timings. We clicked the method Mandelbrot.Algorithm.Evaluate() in the Slowest lines of code list:

Clicking any of the slowest lines of code in the Summary automatically updates the Source code panel to show relevant source code and timings.

It is clear in this example that nearly all the time is spent in the method EvaluateUsingComplexNumbers() as indicated by the red bar. We can drill down to display the source code for the EvaluateUsingComplexNumbers() method by selecting it from the drop-down menu at the top of the Source code panel.

Drill down to view Source code for the chosen method.

Having identified that most of the time is spent in the EvaluateUsingComplexNumbers() method, you might consider whether the method can be made to run more efficiently by writing it to use doubles rather than complex numbers, for example.

If you are interested in a method not listed in the Summary you can go to the All methods panel to see all the profiled methods in a grid.

When viewing the All methods panel you can sort, filter, and group the methods as you want.

When you click any method in the All methods or Summary panel, the Hierarchy panel is updated to show details of the method together with its parents and children. We click the method Form1.DrawMandelbrot() in the grid to find out more information about this method. From the Hierarchy panel you can see that the hit count is 1, so the method was executed once. The Time with children is much greater than the Time, indicating that the method spends the majority of its time in child methods.

Double-click any parent or child to drill down and discover exactly where the time is being spent. 

We can see that most of the time is spent in the method Algorithm.Evaluate() which is executed 115104 times, once for each of the pixels in the image. We can double-click Algorithm.Evaluate() in the Children list to make this the currently displayed method. Then double-clicking Algorithm.Evaluate UsingComplexNumbers() in its children list shows the time is spent in five complex number routines.

A vital development tool

ANTS Profiler is a simple .NET profiler that gives you the information you need simply and rapidly. Appropriate pieces of code can then be optimized, so performance is improved, and hardware requirements are lowered.  It is simple to use, and the results produced make it easy for any .NET developer to understand where bottlenecks or problems lie.

Evaluate ANTS Profiler with your applications to see how well it will work for you - download a free, fully functional, fully supported 14-day trial.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Red Gate Software
Red Gate Software Ltd.
United Kingdom United Kingdom
Red Gate Software makes ingeniously simple tools used by over 650,000 Microsoft technology professionals working with .NET (incl. ASP.NET), SQL Server, Azure, and Oracle. More than 100,000 companies use our products, including 93% of the Fortune 100.

Our philosophy is to design highly usable, reliable tools which elegantly solve the problems that developers and database administrators face every day.
Group type: Organisation

4 members

Follow on   Twitter   Google+

Comments and Discussions

 
QuestionHow to write Performance Profilers PinmemberPattabhirama13-Jun-06 6:34 
AnswerRe: How to write Performance Profilers PinmemberDustin Metzgar13-Jun-06 6:41 
GeneralRe: How to write Performance Profilers PinmemberPattabhirama13-Jun-06 6:49 
GeneralRe: How to write Performance Profilers PinmemberDustin Metzgar13-Jun-06 7:16 
GeneralRe: How to write Performance Profilers Pinmemberatlaste7-Jan-07 20:09 
AnswerRe: How to write Performance Profilers Pinmemberscott_hackett31-Aug-06 2:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 25 Nov 2004
Article Copyright 2004 by Red Gate Software
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid