views:

166

answers:

4

I browsed and read a lot of questions/answers about profilers on StackOverflow, but still have one more question I haven't found an answer to.

I have been using TurboPowers Memory Sleuth for years with Delphi 7 and am still very hapy with it.

However, I plan to upgrade to Delphi 2010 and suspect that this program will not run anymore. So I need to find some replacement.

One of the things I liked very much about Memory Sleuth is the fact that you could select a procedure from the list it compiled from your project, to start profiling.

Typically this was a button click event. That way you could easily profile only some lengthy code you start with a button click, but did the profiler leave out all time for starting your program, displaying it's main form ...

The profiling started at the start of the selected routine, and ended at the end of the selected routine. Mind you, all without changing a single line in your code (a fact that I find very, very important).

Anyone any suggestions which of the profilers currently in existance (and maintained) can do this for me ?

+3  A: 

Take a look at Sampling Profiler. It's not quite as simple as you described, but it's a very good tool, and you can turn profiling on and off for selected procedures with an OutputDebugString call. I think that's about as good as you're gonna get without Embarcadero writing a profiler.

Mason Wheeler
I just looked up Sampling Profiler. I get the sinking feeling that all it samples is the program counter, not the call stack. The problem with that is this: http://stackoverflow.com/questions/1777556/alternatives-to-gprof/1779343#1779343
Mike Dunlavey
+5  A: 

Commercially there's AQTime from AutomatedQA, it's pretty feature rich. It can do what you're asking.

Harriv
Another vote for AQTime. If you have the money, it is the best tool for the job.
birger
I am currently downloading the demo. Gonna try it out together with the ones mentioned in the other reply (aind in some other topics).But first, I'm gonna finish the program I'm writing that will put 36 hours into a working day (to find the time to try them out). Thanks for the info.
Edelcom
@Birger: Depends on what the job is. I've got AQTime and I've got Sampling Profiler, and frankly I prefer Sampling profiler for most things, because it doesn't slow your program down.
Mason Wheeler
I've tried both AQTime and Sampling Profiler. While there is no comparison on speed, it was much easier for me to find exactly what is happening with the function analysis of AQTime.
stg
A: 

AQTime can definitely do this. You can select whatever modules you want to include. But if you're going to Delphi 2010, they don't have it integrated into the IDE yet. In fact just a few weeks ago they finally got their Delphi 2009 integration working - a year after D2009's release, and from my initial look at it, it appears to be buggy.

AQTime is also VERY expensive at $600. If you do go for it, buy if from one of their partners where you can save some money (e.g. Falafel offers it for $500 instead of $600). {Here's my personal rant: That is a terrible policy that turns me off. You should not pay more when you buy direct from the vendor. They should either get their partners to sell at the same price and give them a %, or they should not offer it at their own site at all and just list the partners from who you can buy it.}

But even given those problems, AQTime is the only tool I've found that works admirably well at giving you line by line execution counts and timings. It's the final result it gives that makes it worthwhile, and after many questions and answers re profiling that I've given at StackOverflow over the past year, I may just end up with them (I am into my 3rd trial now that they've added the D2009 integration).

My main Questions are at:

And I've attempted an answer at:

Despite Mason's comment, I do not find that AQTime is too slow for profiling, as long as you only profile the routines that you are currently working on optimizing. Just don't always turn it on for everything.

I had also tried Sampling Profiler. It just didn't work for me. It seemed that 90% of the results it came up with were in System routines, with string copies and moves taking up the majority. That didn't help me. I needed to know which lines in MY routines were calling those moves and copies.

If you want a good free one, I would highly recommend asmprofiler. It is actually an amazingly good profiler, similar to AQTime, with wonderfully great profile results. Its only downfall is that it only analyzes down to the procedure level and not to the line level, and that's the only reason I favor AQTime.

p.s. For Micro Optimization, they say not to rely on AQTime. I've done a good amount of testing now, and I'm getting more and more impressed by the assistance AQTime and it's line-level info gives to help you find those places to micro optimize. That in itself makes the product worth its while.

If line-level information gets added into asmprofiler, then that one will be the no-brainer.

But wouldn't it be nice if Embarcadero finally decided to add a built-in profiler right into Delphi? As I write this, it is in 10th place at Delphi UserVoice. Vote Here to move it up!

lkessler
Thanks for the positive feedback! Didn't know what others thought about it, gives me energy to continue it! I am already thinking about less detailed and less memory consuming profiling mode (just store count + total time, not exact details). I am already working on a PoC sampling profiling (less overhead, click-and-go profiling) with better results than "sampling profiler".About the "line level" profiling: does anyone know how I can do that? I know "Intel VTune" can do that too, but only in Sampling mode?
André
(commented on "asmprofiler" tip)
André
André: A Built in profiler is 10th on the list at http://delphi.uservoice.com/pages/4432-general - so maybe Embarcadero would be willing to work with you to integrate asmprofiler into a future version of Delphi.
lkessler
Apparently the key to "line level" profiling is through the TD32 debug info.
lkessler
+1  A: 

For finding memory leaks, something like AQTime could be best. For finding speed problems, have you considered the simple method of stackshots? It is low-tech but effective. Here's an explanation.

Mike Dunlavey
I don't start profiling when some code seems too slow ... I profile my code when I suspect I can get it to run faster (and I know it's being called several times).I need a program which shows me which routine is called often, and is taking the most of time.Idealy I need a program that shows which line in a selected routine is taking up the most of time. That way I can really speed up parts of my programs. You'd be amazed how much you can improve speed of seemingly optimized code.
Edelcom
@Edelcom: I couldn't have said it better than you did. Here's an example: http://stackoverflow.com/questions/926266/performance-optimization-strategies-of-last-resort/927773#927773
Mike Dunlavey
@Edelcom: There's no reason to profile code on the suspicion it could run faster. Nearly *all* code falls into that category. So what, if it's fast enough? I'm all for designing for efficiency, but this infatuation with micro-optimization and profilers I can't understand. @Mike: Good answer in the link, but I upvoted it already. It shows quite nicely what gains are to be had with macro-optimization.
mghie
I'm not talking about micro optimizations. F.i. I have a program which generated websites. This action is started from behind a button. I will start optmizing the code behind this button because it can take quit some time to generate a comlete site. If I can get that a bit optimized (talking about 30-40%) this can make a big difference. I agree that micro-optimizations can always be performed. It's always a trade off having enough time to optimize code. For macro optimizations this can useally be done, micro optimizations are much hard to take the time for.
Edelcom
@Edelcom: Your problem is exactly what stackshots are good for. Here's a very short explanation of how and why they work. Good luck. http://stackoverflow.com/questions/406760/whats-your-most-controversial-programming-opinion/1562802#1562802
Mike Dunlavey