Recommended C/C++ Performance Profiler?

Started by
5 comments, last by Sneftel 15 years, 2 months ago
We've all had this: I've got some code which doesn't run as quick as I'd like. I need a decent performance profiler to work out the kinks. I'm an experienced C++ games coder who could put one together relatively easily (I'm sort of kicking myself that I've not written one already), but right now I want to spend my time actually playing with my game code, and I need it to run a bit quicker before I can really do that. So I thought it'd be easier in this case to stand on the shoulders of giants, as it were, and ask you guys what you'd recommend. Here's what I'm looking for: - Something easy to drop in. Source code rather than compiled libraries, and if it comes as just one .cpp and one .h rather than a project I've got to integrate into my solution, so much the better. - Something that'll run on Windows, with an Intel processor (although longer-term, the more cross-platform the code, the better) - Something, ideally, that's a bit hierarchical. So I can set timers around certain functions to get an overall timing, but can then set sub-timers around functions that my expensive functions call (or just around suspect-looking blocks of code), to find out how the expensiveness gets subdivided. - Something with a flexible output. Logging stuff to file is okay (so long as it uses whatever buffering techniques it needs to to make that as efficient as possible - wanting the performance profiler to have as little impact as possible on the actual performance is kinda a given), but if there's a way I can easily hack it to use my debug font-renderer to display the stuff onscreen, so much the better. Any suggestions or recommendations?
"We two, the World and I, are stubborn fellows at loggerheads, and naturally whichever has the thinner skull will get it broken" - Richard Wagner
Advertisement
Maybe the Google performance tools could be helpful. Take a look at this:

http://code.google.com/p/google-perftools/downloads/list

You can link them into your own application and adapt it to your requirements.

With best regards,
Kimmi
A complicate solution may indicate a not understood problem.


[twitter]KimKulling[/twitter]
The Google Performance Tools seemed a bit full-on when I downloaded it and opened it up. Lots of files, most of which seemed to be unrelated to performance profiling, and a distincly Linux-y flavour (not that I have a problem with Linux, it's just not what I'm working with).

What I did find, after a bit of hunting around, is something called LTProf: http://www.lw-tech.com/

It's shareware, but pretty reasonably priced (IMHO) for what it is - I got a huge amount of information out of it in a very short time. I have no idea what it does when the trial period expires, whether it actively shuts itself down, or whether it just nags you a bit but runs anyway. It doesn't have to be compiled in with your source code at all, you just run your executable, point LTProf at it as its running, and it spits out a big hierarchical view of where all the processor time is being spent, which you can examine right down to individual lines of code. Very cool.

(For the record, I'm not affiliated with the dudes that make it in any way, it's just something I found that has solved my problem remarkably well, so I thought it might be worth mentioning in case anyone else here is looking for a profiler)
"We two, the World and I, are stubborn fellows at loggerheads, and naturally whichever has the thinner skull will get it broken" - Richard Wagner
The best free profiler in my opinion is AMD CodeAnalyst.

http://developer.amd.com/CPU/CODEANALYST/Pages/default.

I've used most of the commerical profilers, this one is pretty full featured. It does work with Intel chips, but is less full featured.

Give it a try!

Good Luck!

-ddn
I've always used GlowCode at our studio, seems to do the trick.
Quote:Original post by ddn3
The best free profiler in my opinion is AMD CodeAnalyst.[...]
Does it feature any instrumentation? Devpartner's profiler (the version that was free for VS 2002 and 2003) gave awesome output and I haven't been able to find anything remotely comparable. Timer-based profiling doesn't seem anywhere near as accurate, even if it does avoid slowing the program down during profiling.

"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Quote:Original post by Extrarius
Timer-based profiling doesn't seem anywhere near as accurate, even if it does avoid slowing the program down during profiling.

You'd be surprised. Give it enough time and it'll be just as accurate (particularly in functions that take up a large timeslice, which of course is exactly what one is looking for), and even moreso because the trace will more closely resemble real-world situations in time-dependent applications.

This topic is closed to new replies.

Advertisement