Click here to monitor SSC

Andrew Hunter

  • ANTS Performance Profiler 6 Early Access

    Posted Friday, November 13, 2009 12:03 PM | 1 Comments

    The Early Access Program for ANTS Performance Profiler 6 has begun. You can get the new version from the EAP forum, here.

    There are three major new features in this early build, with more to come in the future:

    Sampling

    This new profiling mode is available from the session setup dialog. Sampling works by periodically taking snapshots of the target program's state and using statistics to estimate the amount of time spent in each method.

    This mode is very much faster than instrumentation and is less prone to biasing the results. However, it records much less detail as it is unable to see events that occur in much less than 10 milliseconds, so it is most suited for obtaining a performance overview of an application.

    'Method events'

    Previous versions of the profiler have focussed on finding out how long a method takes to execute. This new feature makes it possible to also find out when a method was running: simply click on a method in the call tree or all methods grid and the time it was running will be highlighted on the timeline.

    Command line tool

    We've added a new command line tool to this version of the profiler. This makes it possible to profile applications and generate reports without using the UI. The intention is that this tool will be used in situations where profiling needs to be automated, for example as part of a continuous integration build process.

  • Commentary

    Posted Monday, June 08, 2009 3:19 PM | 6 Comments

    I write a lot of comments in my code: these days it's second nature. Every declaration I write has a comment describing what it's for and maybe some remarks describing things I think are the associated gotchas. Inside method definitions, I maintain a running commentary describing what the method is supposed to be doing and why. I feel that comments are the best place for code documentation for one simple reason: the source file is the one thing that you can guarantee that a future developer will read.

    This code style is something that has evolved over many years. When I was starting out in development I took a more conventional attitude, that if the code was readable (sensible names, well structured) then it was also automatically understandable. Time changed this attitude. At first, I grew used to looking at the code of other developers and wondering what they could possibly have been thinking while they wrote it and wishing I could throw the whole thing away. Later I found myself wondering the same thing about code that I had written long ago. If I made changes, they would fail in unpredictable ways. The variable names, they did nothing.

    Occasionally the problem turned out to be genuinely bad or lazy code, of course. Mostly, though, the problem was one of understanding. Code written in the languages we have available today explains in great detail the steps taken by a program to complete a particular operation. The name of a method or class will usually explain what the operation is. It gets fuzzier as you 'draw back' from the individual operations and try to get a higher level overview.

    The problem is that developers can usually fill in the gaps in their own code: they can remember writing it and their own reasoning. What seems obvious now might not be obvious to the next developer. At best, this makes their life harder: they need to spend longer looking at the code and its documentation before changes can be made successfully. More often, these 'obvious' things will result in new bugs being introduced during maintenance: at worst, these bugs won't be discovered before the code is in production. It's better to document something that seems self-explanatory now rather than wait until later when nobody remembers why it was supposed to be self-explanatory in the first place.

    So, I set out to document as much as possible, forcing myself to try to write something interesting even about things that seemed they would be obvious. It wasn't particularly easy at first: the idea was to write comments first and code later but I always felt more productive writing code so I'd have to go back and write the comments later. As I was doing this I found something interesting: sometimes by trying to describe what I was doing I would discover what was wrong with it and I'd be able to fix it much earlier.

    I think this idea also appears to be at the heart of the idea of pair programming: if you can't comfortably explain what you are doing, you are probably doing it wrong. I found that by writing about what I was doing before I did it I would spot logic errors and parts that were not entirely thought through much more quickly: by refining my comments I was finding ways to refine the code. This improved my productivity: the code was easier to read, more structured and I avoided introducing bugs - spending time on the comments meant I wrote less code in a day, but I also spent less time fixing it or working around problems I had introduced.

    This is an agile approach to development: documenting design in the code with a 'just-in-time' approach. It works well because it is a focussed way of solving a problem - designing and implementing the solution in a single pass. It's also effective because it makes it easier to keep the documentation in sync; if the documentation is kept in the same place as the thing that it is describing then it's much easier and more natural to keep it up to date as changes are made.

    I think there is a tendency for new developers to eschew comments for reasons that are perhaps ill-founded and which become ingrained. Commenting frequently not only ensures that code remains readable once the original development cycle is distant memory but also provides a time-saving sanity check that can prevent poor code from being written in the first place.

<February 2012>
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
How to Kill a Company in One Step or Save it in Three
 The majority of companies that suffer a major data loss subsequently go out of business. David Wesley... Read more...

Migrating from OCS 2007 R2 to Lync: Part 4
 Having migrated the rest of our users and legacy resources across, and start getting ready to... Read more...

Automated Script-generation with Powershell and SMO
 In the first of a series of articles on automating the process of building, modifying and copying SQL... Read more...

Seth Godin: Big in the IT Business
 Seth Godin has transformed our understanding of marketing in IT. He invented the concept of 'permission... Read more...

Using SQL Test Database Unit Testing with TeamCity Continuous Integration
 With database applications, the process of test and integration can be frustratingly slow because so... Read more...