The Developers Toolbox...
The developer’s toolbox, like any professional’s tool collection is best when it’s bristling with implements that augment a workers talent, and when applied by a knowledgeable person seemingly allow miracles. As a developer I have a great number of such tools in my toolbox. Some of which I have developed myself. Others I have purchased from the market. One of the most valuable such tool is a product that I purchased from a company called Red Gate (http://www.red-gate.com). Its name is the ANTS Profiler.
The Ants Profiler (here to fore called ANTS), is a .NET application performance/resource consumption profiler that allows the .Net developer to meter the performance and memory consumption characteristics of their .Net applications. It will allow the profiling of .Net 1.1 and 2.0 applications and in its current version (3.0.0.342) integrates directly into the VS2003 and VS2005 environments from the drop down menus within the IDE itself( this is new in version 3+ and makes the software easier to use). I have used the application as it exists now on every version of windows since 2000 and I am currently running it on my Vista Ultimate development machine. Having used the product for a number of years now I have found it to be so useful that I can not fathom living without it.
Using the application to conduct a performance profile of a running .Net application is about as easy as it gets, basically breaking down in 4 steps…
- Compile the application in Debug mode so it generates a .PDB file as well as the executable.
- Open the Ants Profiler interface and point it at the executable file you want to profile.
- Select a few options (like profile just what you have source for or all .Net methods, and what command line parameters you might want to pass along to the running application).
- Run the app through the paces you want to profile.
When you have completed and exited the application, the Ants profiler will display three different groupings of performance characteristics.
- Slowest Lines of Code
- Slowest Methods
- Slowest Methods with Children
(note) these lists are top 10 and can be expanded to show each category in their entirety
A window at the bottom of the display will show the actual code for the application for the items selected from the top three sections. Click on a slow line of code and ANTS will pop to that line in the bottom window. It will show you the source file where the line is located, what line number it is, how many times the line executed, and finally how long the system spent executing that line of code. Using the navigation tools that ANTS provides, allows the developer to easily pinpoint trouble areas in their application, areas in need of modification to bring performance up to desired levels. ANTS, excels at showing the developer where in the code the bottlenecks are located. It’s up to the developer to determine how to fix the problem however, ANTS provides you with all the necessary information.
ANTS also allows you to save the results of any profiler run off to a file. You can then tweak your code and re-profile the application comparing the results on the second profiler run with the results of the first. This back and forth between the IDE to craft a tweak and ANTS to gauge the tweaks effectiveness is fluid and natural feeling and greatly enhances the tools usability. Few things in a coders experience are as satisfying as seeing a slow method fall off the top 10 list in the ANTS results after a tuning session with ANTS. Something just seems right with the limited world of a coder and ANTS delivers the goods.
An actual example where I used the profiler results to fix a performance issue showed me that a particular set of code lines were executing in a custom file importer we had written for a set of clients. In this case these lines needed to be run through once for each line of text file being parsed. In this case there were 12 elements on each of these lines that needed to be parsed as dates. ANTS showed that while the methods attached to the DateTime class were real handy for ensuring the integrity of data being passed through them, their performance was underwhelming. Multiply this sluggishness by the millions of times they were being invoked, and you get the idea. Using ANTS I was able to see this clearly and found that I could write my own validation using simple string manipulation to create the same functionality I needed while boosting performance considerably. (In this case an 80% reduction in execution time of these snippets of code). The importer was then able to process its file in 30 minutes rather than 4-5 hours.
Another particular instance showed that our own Grid control that we had written many moons ago suffered from a particularly bad design, (My fault of course as I developed the thing for our company). ANTS allowed me to see that I was being incredibly wasteful in the instancing of objects to hold the individual cells of the grids data, each cells formatting characteristics, Fonts, Colors, and other state information. ANTS showed the error of my ways to me and allowed me to rethink the way the grid itself was architected. Now our Grid control is used in everything we write and it runs like greased lightening even with millions of cells of data housed within.
Performance gains like those above have been enjoyed by my development team and I, on more than a couple of occasions. So enamored am I with the tools ability to show problems in execution pathways that I use ANTS to test the performance of every application I write and reuse it on any application I perform any significant rework or enhancement to. For your performance gauging needs on any of your .Net application under development ANTS has proven to us to be an invaluable tool for the job. Reasonably priced, easy to use, I would not hesitate to recommend it to anybody with the need for .NET speed.
0 Comments:
Post a Comment
<< Home