Stuff

A common belief is that you should always profile your code first to diagnose a performance problem before trying to optimize. This is generally a good idea, although sometimes it's taken to absurd extremes. You don't really need a profiler to see that an O(N^2) algorithm with N=40000 is likely a problem -- all you need is to break into the app with a debugger a few times. That having been said, the quicker your profiler is to use, the easier it is to just use the profiler and get some hard data. There's nothing like a profile showing a particular function at 98% of the CPU to identify a culprit.

It seems that most people I know prefer call graph profiling for the detail of data produced, but I like sampling profilers myself, because they're less intrusive and the data is more reliable, although less precise. They also often have the nice advantage that you can simply start them at any time and nonintrusively profile the whole system on the spot, without having to launch the application under it or terminate the app when profiling completes. Therefore, when the program I was working on was unexpectedly running one-third of the speed that it should have, I just launched AMD CodeAnalyst and fired off a standard 20-second no-launch sampling run (which is in a profiling project named "whatever").

The result?

Well, the profile showed a bunch of function names that started with @ILT... which, if you're familiar with Visual C++, stands for "incremental link table." Which means that the reason that the program was running slowly was that I was running the unoptimized debug build.

Sheepishly, I stopped the program, changed the configuration from Debug to Release, and solved the performance problem of the day.

one comment | Sep 28, 2009 at 17:40 | default

Comments

Comments posted:

I always enjoyed your blog for your technical accuracy and rock solid programming skills; but this one really made my day!

Dinsdale - 23 11 09 - 07:32

Comment form

Please keep comments on-topic for this entry. If you have unrelated comments about VirtualDub, the forum is a better place to post them.

Name:

Remember personal info?
YesNo

Email (Optional):

Your email address is only revealed to the blog owner and is not shown to the public.

URL (Optional):

Comment:

/

An authentication dialog may appear when you click Post Comment. Simply type in "post" as the user and "now" as the password. I have had to do this to stop automated comment spam.

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.