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

Why You Should Own a Code Profiling Tool

, 5 May 2008 CPOL
Find out why you should invest in a code profiling tool and what difference it can make to your applications.

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.

Contents

  • Introduction
  • Why Sluggish Applications Cannot Be an Option
  • Life without a Code Profiling Tool
  • Why You Should Own a Code Profiler
    • Stop Guessing: Use Real Data
    • Keep an Audit Trail of Code Changes and Performance Improvements
    • Efficient Testing as Part of an Effective Quality-assurance Effort
    • Make Better Design Choices
    • Reduce Hardware Costs
  • Why ANTS Profiler is the Market Leader
  • Conclusion

Introduction

This document highlights a few of the reasons why you – or your development team – should invest in a code profiling tool. First, we demonstrate how critical your development work is and how it affects your organization as a whole. We then expose why you need to avoid manual trial and error processes, and why having a profiling tool in your development toolkit is so vital. The last section offers an insight into why ANTS Profiler is the market-leading code profiler.

Why Sluggish Applications Cannot Be an Option

For most organizations, bloatware – i.e. sluggish or unresponsive software – is not an option. Web pages that take too long to load, an unresponsive shopping cart or, worse still, an application that hangs, will cause customers to lose confidence in your software, and can even stop them purchasing from your company.

There is nothing more frustrating than having to wait needlessly for a web application to finish processing. Simon Galbraith, Joint CEO at Red Gate Software, demonstrates in a Simple-Talk article [^] how users begin to abandon websites if they have to wait more than 5 seconds for a page to download.

Simon Galbraith's findings are supported by a Jupiter Research report [^] from 2006 which found that 33% of consumers shopping via a broadband connection will wait no more than 4 seconds for a Web page to render. This suggests that your HTML must be served to the client in less than 1 second, even when your server is under heavy load, as you need to allow time for their browser to download additional images and perform the processing necessary to display the page.

The same research also points out that over 33% of shoppers who were dissatisfied with a retail site's performance (website too slow, site crash, error message received, etc.) abandoned the site.

Further to this, a study of 12,000 online consumers reported by ZDNet (2002) revealed that 48% of those interviewed had given up trying to purchase products when web pages took too long to download.

These principles also apply to desktop applications, whether they are used by end-users internally or externally. End-users are quick to complain if the programs they use on a daily basis are too sluggish for their liking. They will demand constant technical support and general productivity will go down. Then, just when you have plenty of other things on your plate, you'll be asked to fix the problem.

The results are conclusive: end-users do not like sluggish software – and you won't like it either, once you see how much it's costing your company.

In essence, every professional developer, whether developing web applications or desktop applications, needs his or her code to run quickly and efficiently. The big question, however, is: "How do you ensure that your code is quick and efficient?"

Life without a Code Profiling Tool

Finding performance bottlenecks is not an easy task without a code profiler. You can use trial and error, sometimes spending hours, days, and even weeks blindly chasing performance issues. So much for productivity!

Additionally, you could waste even more time tuning code that is not the cause of any problem. It is rare for a bottleneck to be in the obvious place, and what is the point in spending time optimizing code that is never called?

Why You Should Own a Code Profiler

A code profiler is an essential tool to have in your development toolkit. It helps to dramatically reduce the amount of time taken to find problem code, by quickly identifying the exact cause of a performance bottleneck, so that you can focus on your code optimization.

Stop Guessing: Use Real Data

A code profiling tool takes the guesswork out of optimizing code. It can provide quantitative data -- such as code timings and hit counts -- allowing you to stop guessing and zero in on key issues. Instead of spending time locating the bottlenecks, you can now use your time effectively and obliterate bottlenecks while those around you are still hunting for them.

A code profiler analyzes your code in minutes, and the results allow you to:

  • Know how your code performs
    You may have just joined a company, or you may not have worked on a particular application, and you are being asked to look into somebody else's code, perhaps your predecessor's. Examining someone else's code when you are not familiar with it is a difficult job. A code profiler that can analyze the code for you before you get stuck in it will allow you to gain a better understanding of the application structure and how the code runs. In cases where you do develop the application yourself, understanding how your code behaves, where each piece of code is being called from, whether it goes into unnecessary loops, and so on, gives you immense knowledge and power. It means that you can fix any issues before shipping, rather than waiting for your customers to report problems. Doing this allows you to release resilient applications and code that you can be proud of.
  • Locate performance bottlenecks quickly
    Reducing the amount of time it takes to find bottlenecks means you can get on with the work of fixing inefficient algorithms, eliminating the bottlenecks, and achieving the results you want, faster.
  • Optimize your code – only where it is necessary
    Queuing theory tells us that the maximum throughput in a system is limited by the component with the lowest throughput. So, to improve the system's performance, you only need to improve the performance of the component with the lowest throughput.

It's so much easier to make an algorithm run more efficiently when you know exactly where to focus your performance-boosting work.

Keep an Audit Trail of Code Changes and Performance Improvements

Aside from the essential arguments listed above, code profiling throughout the development cycle allows you to keep an audit trail of performance improvements made over time. As your application changes and grows in size and quality, managers generally like to have a means of monitoring the code at intervals throughout the development cycle. They want to know that performance trends are moving in the right direction and that applications aren't becoming unnecessarily complex and unstructured. The only way to keep track of this is to profile your code after each critical milestone.

Efficient Testing as Part of an Effective Quality-assurance Effort

Any significantly-sized piece of software contains bottlenecks, just as it will contain bugs. It's inevitable; it's part of the job. What's avoidable, however, is wasting unnecessary time looking for, and fixing, bottlenecks and bugs. Furthermore, the earlier you find and fix a bottleneck or a bug, the cheaper it is to fix. An industry rule of thumb is that a bug that costs $100 to fix before shipping can cost $1,000 to fix after shipping.

Looking for a bug and fixing it two weeks after it was introduced is going to be much easier than finding and fixing a bug that was introduced two months ago. For one thing, the "surface area" of changes in that period is going to be smaller, and the code will be fresher in your mind.

This is why using a code profiler after each milestone is vital. It will save you hours, days, and sometimes weeks when you are pressed for time later down the line. You will sometimes have to rewrite large amounts of code, or code which you thought was stable, after discovering that parts of it do not perform as well as expected. Then, of course, once the code has been rewritten and tested, something else might break and need fixing.

Testing for bottlenecks and bugs late in the development process leaves you very little time to fix issues and, where it is deemed too risky to drastically optimize code at a late stage, it greatly increases the likelihood of a poorly-performing application being released. This would reflect badly on you, your team, and your department. Yet it is so easy to minimize risks simply by profiling your .NET code regularly during the development phase, after each critical milestone. The time, money, and stress it saves you down the line are always worth it.

Using a code profiler for quality assurance during your development phase will allow you to measure the quality of your software and make sure that you reach a given performance standard. It allows QA Managers and Software Managers to streamline test plans and allocate most of the time and resources to the most critical part of the code (saving on excessive time spent on areas of the program where the risk of defects is low).

Make Better Design Choices

If used early on during the development phase, a profiling tool can also help you make design choices based on the profiling results. You can compare the performance of different approaches and make sure your application is scalable early on in the project, avoiding costly problems later on.

Reduce Hardware Costs

If you can make your application run faster, you can accommodate more requests per server, and therefore utilize less hardware. By using a code profiler throughout the development process, and optimizing performance, you will also be better able to assess hardware requirements and, potentially, reduce hardware costs.

Why ANTS Profiler is the Market Leader

Whether you are developing in C#, VB.NET or managed C++, you will be looking for optimum performance from your code. ANTS Profiler identifies performance bottlenecks in applications written in any of the languages available on the .NET Framework. During the performance profiling, ANTS Profiler records the frequency and time it takes for each line of code to be executed, as you are using your application. ANTS Profiler provides you with detailed quantitative data, including the 10 slowest lines of code, 10 slowest methods, slowest methods with children, line-level timings, and hit counts. These detailed results allow you to quickly identify performance bottlenecks and optimize your .NET application accordingly.

source_code_view.png

Source code view: ANTS Profiler provides you with detailed profiling results, including line-level timing, so you can drill down to the specific lines of code responsible for performance inefficiencies.

ANTS Profiler's main strengths are:

  • Ease of use
    ANTS Profiler is designed so that you can profile your application and get results within minutes, without having to read a manual. The simple, 4-step profiling wizard is straightforward to use and there's no scripting involved.
  • Flexibility
    The Pro version of ANTS Profiler offers maximum flexibility. You can profile in Detailed Mode (for line-level timings), or in Fast Mode (method profiling). You can even profile the memory of your application if you suspect memory leaks.
  • Detailed, clear results
    You will get detailed, yet easy-to-understand results, enabling you to quickly identify your performance bottleneck or memory leak.
  • Good value
    To keep things simple, the tool is not overloaded with unnecessary features. You do, however, get all the key features to help you get on with your job... without the heavy price tag.
project_wizard.png

Key features:

  • Visual Studio integration
    ANTS Profiler can be accessed directly from VS 2003/2005, allowing you to start profiling your code quicker, by simply clicking on the ANTS menu item. ANTS Profiler is then launched automatically with the executable already set.
  • Detailed mode performance profiling
    ANTS Profiler offers clear and detailed profiling results with line-level timing, so you can quickly identify the specific lines of code which are affecting the performance of your application.
  • Fast mode performance profiling (Pro version)
    This feature will let you profile your code around ten times quicker than the detailed mode and is the option to choose if you need to get an overview of the slowest methods, so you can decide which ones to investigate further.
  • Profiling API (Pro version)
    The API gives you greater control over the profiler by letting you take snapshots exactly where you want, as well as enable or disable the performance profiling where you decide it's necessary.
  • Memory profiling (Pro version)
    The memory profiler lets you take multiple snapshots at different times while your application is running, so you can compare application memory states. This feature is ideal if you need to investigate your application's memory usage and locate memory leaks.
vs_ants_menu.png

Conclusion

Developers working on complex applications often find themselves spending days, or even weeks, tracking bottlenecks down to their roots. A developer typically costs a company around $1,000 per day (with salary, employer's contributions, and so on). Considering that you can buy ANTS Profiler Pro for just $495 per license, you only need your developer to use the profiler once or twice per project to see a return on your investment.

License

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

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

 
GeneralNice But Need More Description PinmemberAbhijit Jana22-Aug-08 21:05 

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
Web02 | 2.8.141029.1 | Last Updated 5 May 2008
Article Copyright 2008 by Red Gate Software
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid