How Does AQTime Do It?
Asked Answered
G

4

13

I've been testing out the performance and memory profiler AQTime to see if it's worthwhile spending those big $$$ for it for my Delphi application.

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.

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.

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

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

Goggler answered 26/11, 2008 at 22:2 Comment(1)
AQTime is FABULOUS. I love it. TOTALLY recommend it.Stinkhorn
S
7

This is just speculation, but perhaps AQtime is based on a technology that is similar to Microsoft Detours?

Detours is a library for instrumenting arbitrary Win32 functions on x86, x64, and IA64 machines. Detours intercepts Win32 functions by re-writing the in-memory code for target functions.

Sword answered 27/11, 2008 at 4:37 Comment(2)
Must be! Barring someone knowing something different, I'm giving you the answer.Goggler
Some people call it "hooking". MadCodeHook is a tool for Delphi that will let you instrument code. Interestingly, one limitation of code hooking is that you can't hook functions that are too short to allow an inline modification. AQTime reports functions that are too small to allow hooks, and all you can do is ignore them. This makes me think that for sure, hooking (instrumenting, intercepting) is what AQTime does.Stinkhorn
V
9

I've made an open source profiler for Delphi which does the same: http://code.google.com/p/asmprofiler/

It's not perfect, but it's free :-). Is also uses the Detour technique. It stores every call (you must manual set which functions you want to profile), so it can make an exact call history tree, including a time chart (!).

Valentine answered 23/3, 2009 at 8:38 Comment(2)
Thanks and great work, Andre. I'm going to try it out. The Delphi community could really use a profiler integrated right into Delphi's IDE. Since you've got it Open Source, you might want to consider donating it to Embarcadero and they might include it. Or market it for $200 a pop.Goggler
Now it does have one! RAD Studio XE Enterprise and ARchitect include AQTime Lite now. It's built right in. ANd if you buy AQTime pro, it integrates totally into the IDE or you can use it standalone.Stinkhorn
S
7

This is just speculation, but perhaps AQtime is based on a technology that is similar to Microsoft Detours?

Detours is a library for instrumenting arbitrary Win32 functions on x86, x64, and IA64 machines. Detours intercepts Win32 functions by re-writing the in-memory code for target functions.

Sword answered 27/11, 2008 at 4:37 Comment(2)
Must be! Barring someone knowing something different, I'm giving you the answer.Goggler
Some people call it "hooking". MadCodeHook is a tool for Delphi that will let you instrument code. Interestingly, one limitation of code hooking is that you can't hook functions that are too short to allow an inline modification. AQTime reports functions that are too small to allow hooks, and all you can do is ignore them. This makes me think that for sure, hooking (instrumenting, intercepting) is what AQTime does.Stinkhorn
P
2

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.

Perimeter answered 26/11, 2008 at 22:7 Comment(0)
M
2

The long-since-defunct TurboPower also had a great profiling/analysis tool for Delphi called Sleuth QA Suite. I found it a lot simpler than AQTime, but also far easier to get meaningful result. Might be worth trying to track down - eBay, maybe?

Mandimandible answered 26/11, 2008 at 22:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.