Sign in to follow this  
ElectroDruid

Recommended C/C++ Performance Profiler?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this