<p>I've been testing out <a href="http://www.automatedqa.com/products/aqtime/" rel="noreferrer">the performance and memory profiler AQTime</a> to see if it's worthwhile spending those big $$$ for it for my Delphi application. </p>

<p>What amazes me is how it can give you source line level performance tracing (which includes the number of times each line was executed and the amount of time that line took) without modifying the application's source code and without adding an inordinate amount of time to the debug run.</p>

<p>The way that they do this so efficiently makes me think there might be some techniques/technologies used here that I don't know about that would be useful to know about.</p>

<p>Do you know what kind of methods they use to capture the execution line-by-line without code changes? </p>

<p>Are there other profiling tools that also do non-invasive line-by-line checking and if so, do they use the same techniques?</p>

I don't know about Delphi in particular, but a C application debugger can do line-by-line profiling relatively easily - it can load the code and associate every code path with a block of code. Then it can break on all the conditional jump instructions and just watch and see what code path is taken. Debuggers like gdb can operate relatively efficiently because they work through the kernel and don't modify the code, they just get informed when each line is executed. If something causes the block to be exited early (longjmp), the debugger can hook that and figure out how far it got into the blocks when it happened and increment only those lines.
Of course, it would still be tough to code, but when I say easily I mean that you could do it without wasting time breaking on each and every instruction to update a counter.