Click here to Skip to main content
15,918,109 members
Articles / Web Development / IIS

Profiling the Performance of a .NET Application

10 May 2007CPOL10 min read 72.8K   41   2
ANTS Profiler provides you with a quick and easy way of identifying performance bottlenecks within your .NET applications. Additional support for the latest .NET 3.0 features, the Vista operating system, and Visual Studio integration, cements ANTS Profiler as a leading tool in performance profiling.

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

Image 1

This is a showcase review for our sponsors at The Code Project. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers.


Not much has changed in terms of users' requirements for a high-performing application over the past two years since I last reviewed ANTS Profiler. Certain aspects of development have become simpler, while others have introduced new degrees of complexity. One thing is for sure, though: developers still face considerable challenges when trying to determine and improve the performance characteristics of their applications.

Luckily, ANTS Profiler has evolved with the technology to provide a quick and easy way of identifying performance bottlenecks within your .NET applications. Version 3 is the latest version of ANTS Profiler and provides more features and full support of the current .NET runtime.

What to Profile

The CLRProfiler concentrates only on the profiling of memory within your application, whereas ANTS Profiler can profile both memory and time-related performance in your application. The standard version of ANTS Profiler that I will be reviewing here provides metrics around duration and time-based performance. It's worth noting that ANTS Profiler Professional edition also deals with memory profiling.

In my review of a previous version of ANTS Profiler, I compared the tool with the CLRProfiler. Rather than perform another comparison here, I can confirm that the results of that comparison are still valid. That is, ANTS Profiler provides a quicker and easier method to identify performance bottlenecks within your application. This is not to say that the CLRProfiler should not be used, but rather used in conjunction with ANTS Profiler. The slowest areas in your application can be identified very quickly with ANTS Profiler. The CLRProfiler can then be used to 'deep dive' into the convoluted aspects of memory management within that particular area of your application. Memory usage and performance are very tightly related in .NET application, and one should not be investigated without considering the other.

The Basics

ANTS Profiler provides a concise summary of which methods and lines of code took the longest to execute during the profiling process. A summary of these methods is the first thing you see when you profile an application, and this is the real advantage and power of ANTS Profiler. An example best demonstrates this.

Let's examine the screenshot below of the summary screen within ANTS Profiler. Without even looking at the code, we immediately know which pieces of code took the longest to execute and where to start our examination to increase the performance of the application.

Screenshot - Figure1.gif

Figure 1: Initial Screen after profiling an application

This particular application is not very large, nor very complex. We can see this within the Slowest Lines of code section of the immediate areas of interest.

Screenshot - Figure2.gif

Figure 2: Slowest lines of code

The slowest line is initially the 'Main' entry point of the application, which stands to reason, as it will execute for as long as the program is running. The second slowest line of code is the line that executes the EncryptData method. This is verified by the Source code view at the bottom of the screen, clearly showing the line being executed and its duration of execution.

Screenshot - Figure3.gif

Figure 3: Source code view

The Source code view shows the line of code that executes the EncryptData method. The view also indicates that this is the slowest line of code with a full red bar. In addition, we can see that it took 0.259 seconds (259 milliseconds) to execute.

By clicking on the EncryptData entry in the Slowest lines of code window, the Source code view is updated to reflect the execution time within that method.

Screenshot - Figure4.gif

Figure 4: Updated Source code view

Within the EncryptData method, we can see that the GetEncryptor method was the slowest to execute (as indicated by the full red bar), and that it took .0250 seconds (250 milliseconds) to execute. Again, this is verified within the Slowest methods window display.

Screenshot - Figure5.gif

Figure 5: Slowest methods

Finally, clicking on the GetEncryptor method within the Slowest methods window updates the source code display to show us the slowest executing line within that method.

Screenshot - Figure6.gif

Figure 6: Update Source code view - GetEncryptor

Here we can see that the line:

TripleDES crypto = TripleDESCryptoServiceProvider.Create();

took 0.244 seconds (244 milliseconds) to execute. This represents a majority of the time and is effectively the slowest part of the application.

So with a few mouse clicks, we have already narrowed down the slowest portion of an application we have no idea about. While this is not a realistic scenario, as typically we would have some context around the application we are profiling, it highlights the ease and speed about which ANTS Profiler can identify the performance areas of concern in our application.

And That's Not All…

The previous section showed a brief introduction into ANTS Profiler's functionality and touched on the performance summary screen, where the most value in terms of performance information is typically gleaned.

Now let's take a broader look at the features provided by ANTS Profiler.

ANTS Profiler can profile a range of application types. The wizard dialog best illustrates this where the type of application is specified.

Screenshot - Figure7.gif

Figure 7: Type of Application to Profile wizard dialog

All the different types of .NET applications can be specified, including ASP.NET web applications. New in version 3 is the support for profiling applications using the ASP.NET development web server that comes with Visual Studio® .NET (commonly referred to by its code name 'Cassini').

ANTS Profiler allows easy profiling via a simple wizard that initiates the profiling operation. All the settings specified can be saved as a profiling project, then loaded and initiated. This is good for recording an original performance profile of your application, called a baseline, and saving those results. Typically, we would then modify the application to address any performance issues that were identified, reload the profile project, re-run the profiling operation, and save the new results. The results generated can be saved and reloaded as required; they can then be used to compare previous runs with existing runs to see if the modifications were effective. The results themselves are listed in ANTS Profiler's Results window. This window holds links to each set of results and is shown in the following diagram:

Screenshot - Figure8.gif

Figure 8: Results window

To demonstrate this, we shall use our previous example at the beginning of this article. In that example, we identified that the following line:

TripleDES crypto = TripleDESCryptoServiceProvider.Create();

was taking the longest to execute and was the major factor of the performance profile of our sample application. Clearly, the code is instantiating a cryptographic provider based on the TripleDES algorithm. To make this a little faster (although a little less secure), we will instead use a simple DES algorithm which is not as comprehensive as TripleDES, but neither is it as computationally intensive. The modified line then becomes:

DES crypto = DESCryptoServiceProvider.Create();

Now, when we re-run the profiling project, we can see from the following diagram:

Screenshot - Figure9.gif

Figure 9: Modified performance run - Source Code Window

that the instantiation of a cryptographic provider based on the DES algorithm takes 0.204 seconds (204 milliseconds), compared to 0.244 seconds (244 milliseconds) previously. While not much of a benefit singularly (40 milliseconds is indistinguishable), in a high throughput application, perhaps dealing with hundreds of thousands of users, any improvement is beneficial. Additionally, this kind of performance benefit is easily identified. It would certainly take much more time to identify it without a profiling tool like ANTS Profiler.

The Bigger Picture

To round out the information provided by ANTS Profiler, we can select the All methods tab to show all the methods executed as part of the profile run. This view provides a summary of all the methods executed within the profile run:

  • Time: how long the method took singularly (not including child methods).
  • Time with children: how long the method took to execute, including child methods.
  • Hit count: number of times the method was executed.
  • Source file: the source code file that the method is in.
Screenshot - Figure10.gif

Each column can be sorted by simply clicking on the associated header column to allow for very simple grouping. This is a really good way to obtain a complete overview of your application's performance and also a complete view of every single method executed within our applications profile run. Combined with the initial summary view, we can create a comprehensive performance profile of our application for very little effort.

New Features

Almost all the features discussed so far have been available in previous versions of ANTS Profiler. So what about the new features in version 3?

Enhanced Graphical User Interface

Organization of windows and interface elements have been made more flexible. The GUI also includes a new docking ability to make it more like Visual Studio in terms of behavior and ease of management.

Integration with Visual Studio

When ANTS Profiler is installed, a new menu is available within Visual Studio that invokes ANTS Profiler and immediately launches the profiling wizard. Conveniently, the wizard will automatically bring up the application being developed within Visual Studio.

Screenshot - Figure11.gif

Figure 101: ANTS Menu within Visual Studio

Support for the ASP.NET Development Server

ANTS Profiler supports profiling of applications using the ASP.NET Development Server, code-named 'Cassini'. In a similar way to the integration feature, this is another facet of support that ANTS Profiler provides with the latest version of Visual Studio.

Fast Mode Performance Profiling

This method of profiling allows faster profiling of applications than standard. Typically, an application's performance can worsen when being profiled, due to the intrusive nature of profiling. Fast mode alleviates some of this, but this feature is only available within the ANTS Profiler Professional edition.

Profiling API

ANTS Profiler now exposes an API (Application Programming Interface) that allows profiling actions of ANTS Profiler to be accessed and controlled by your own applications.

Support for 64-bit Applications

64-bit applications are more prevalent and will be more so in the future. ANTS Profiler fully supports profiling these types of applications.

Support for All the Latest .NET 3.0 and Related Features

ANTS Profiler has been updated to fully support the Microsoft® Windows® Vista® operating system and the Internet Information Server 7 that comes with Vista. In addition, there is support for the latest series of .NET features, such as .NET 3.0 Framework, Windows Communication Foundation, Windows Workflow Foundation, Windows Presentation Foundation, and XBAP technologies.

Viewing an Export of Profiling Results After the Trial Period has Expired

One of the more interesting features of the latest version of ANTS Profiler is the ability to view and export profiling results after the expiry of the trial version period. Clearly, this is a show of support from Red Gate, effectively acknowledging that some people will utilize the trial version of the software to profile their applications and could then go on to purchase a copy. And because Red Gate knows that these people will find the software so useful for their requirements, Red Gate doesn't want to hamper profiling efforts just because you used the trial version. At least that's my interpretation anyway....


The latest version of ANTS Profiler has evolved over time to support all the latest technology sets and features. The first version of ANTS Profiler offered quick, painless performance profiling with comprehensive results, for very little effort. This basic mantra has not changed, and it is the core advantage of using ANTS Profiler.

Additional support for the latest .NET 3.0 features, the Vista operating system, open API design and additional Visual Studio support and integration, cements ANTS Profiler as a leading tool in performance profiling, where time and value for money are all-important.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

QuestionFree alternatives? Pin
Phil2767-Oct-07 0:07
Phil2767-Oct-07 0:07 
AnswerRe: Free alternatives? Pin
Florian Standhartinger16-Jul-12 10:29
Florian Standhartinger16-Jul-12 10:29 

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

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