ANTS Profiler 3.0
.NET Profiler for Performance and Memory Usage
By Steve C. Orr
Nobody writes perfectly optimized code on their first attempt. In fact, most experienced programmers will tell you that it s a bad idea to even try because optimizing code that is not a bottleneck generally doesn t make a program run any faster and trying to guess which parts of a program will run slowest is usually futile. Therefore, it s generally best to write code first, then identify bottlenecks and optimize them. Of course, the big question then becomes, How do I identify the bottlenecks? Without a tool such as ANTS Profiler, there is no easy answer to that question.
So How Does It Work?
ANTS Profiler observes a program as it runs and takes detailed notes about which parts take the longest to execute and which objects eat the most memory. It allows you to drill all the way down to individual lines of code to identify promising optimization targets. Each line of code has its execution time precisely measured and the results are color coded, so it rarely takes more than a glance to see which code segments need the most attention. Each instantiated object has its memory footprint measured so you can tell where all that RAM is going (see Figure 1). Various snapshots can be taken throughout the execution of the program to reveal how the memory footprint changes over time. This can be pivotal for tracking down memory leaks or optimizing inefficient memory usage.
Figure 1: Every object instantiated in your program can have its memory footprint measured at various points during execution to help track down memory leaks and inefficient memory-hogging functions.
One of your first tasks when you start ANTS Profiler (from the Windows Start menu or from the integrated Visual Studio menu) is to choose which kind of program you want to profile. You can profile desktop applications, ASP.NET Web applications, Windows services, or COM+ server applications (see Figure 2).
Figure 2: ANTS Profiler can profile most major types of .NET applications.
The user interface could perhaps be a bit more intuitive, but anyone brainy enough to be profiling software applications should be able to figure it out with no more than 30 minutes of tinkering. Essentially, the largest objects or slowest performing functions are listed at the top, and each item below is progressively less significant. Clicking on an item in the list will let you drill down through its children and all the way down to the underlying lines of code. The results pane is rather hidden over on the right side of the ANTS Profiler main window, so keep an eye out for it because it s essential for comparing various snapshots taken throughout the execution of your program (to see how things change over time).
I put the ANTS Profiler through its paces with a sluggish program on which I d been working. It clearly identified which functions and lines of code were the slowest. Using this knowledge, I was able to restructure my program and use some alternate functions to improve dramatically the speed of my application. It was also able to put my mind at ease about a suspected memory leak. Indeed, this program does live up to its promises.
ANTS Profiler supports operating systems ranging from Windows 2000 through Windows Vista, and even Windows Server Longhorn (which was still in beta at the time of this writing). It also supports all the latest .NET 3.0 technologies, such as Windows Communication Foundation (WCF), Windows Presentation Foundation (WPF), and Windows Workflow Foundation (WF). It will profile any .NET language not only C# and VB.NET, but also managed C++, Cobol.NET, and virtually any other .NET variation you may discover. IIS versions 5 through 7 are supported, and even ASP.NET s built-in Cassini Web server is supported, as well. Likewise, 64-bit applications are no problem.
The ANTS Profiler Web site has some jaw-dropping features to get you started in no time. The demonstration video will show you in moments how simple the ANTS Profiler program can be to use; the walk-throughs are yet another innovative and intuitive product introduction. After exploring these useful items I had to wonder why every software company doesn t have such useful features on their Web sites.
Of course, their Web site also contains all the other usual support you d expect from a professional software company, such as a FAQ section, knowledge base, forums, documentation, etc. Personalized e-mail and phone support contracts can be purchased for 25% of the product price.
The single-user price of US$295 for the ANTS Profiler standard edition is reasonable, considering the time it saves and the dramatic performance increases it can help achieve. The memory profiling is only available in the professional version, which costs US$495 and includes a profiling API. For an extra US$100 you can get an ANTS Bundle, which includes all the above, plus load and stress testing tools for Web applications.
Every self-respecting software developer wants code that runs quickly and efficiently. However, by looking at the large number of bloated applications out there it s clear that more developers should be using tools such as ANTS Profiler. Without such a tool, effective optimizing code can be quite challenging and is too often left undone. To avoid contributing to the global epidemic of bloatware, I suggest you download the free 14-day trial of ANTS Profiler to see firsthand what it can do for your code and your reputation as a software creator.
Steve C. Orr is an ASPInsider, MCSD, Certified ScrumMaster, Microsoft MVP in ASP.NET, and author of the book Beginning ASP.NET 2.0 AJAX by Wrox. He s been developing software solutions for leading companies in the Seattle area for more than a decade. When he s not busy designing software systems or writing about them, he can often be found loitering at local user groups and habitually lurking in the ASP.NET newsgroup. Find out more about him at http://SteveOrr.net or e-mail him at mailto:[email protected].
Price: Starts at US$295