views:

155

answers:

4

I've used two profiling tools (VTune on windows and dbx (within sunstudio) on Solaris) which can profile program without rebuild them, and during profiling, the program just run at the same speed as normal. Both of these 2 features saved me a lot of time.

Now I want to know if there is some free tools available on Linux platform can do the same thing. I think I need profiling tools based on sampling. VTune is good but expensive ... I've heard of gprof and valgrind. But seems gprof need instrument the program (so we have to rebuild the program) and valgrind will slow down the program execution quite a lot. (from valgrind's introduction, Cachegrind runs programs about 20--100x slower than normal, and Callgrind which I need to profiling is based on Cachegrind)

For profiling, I just need to figure out the execution time of function calls so I can find out where the performance degradation happens. Actually I don't need many low level profiling information as Cachegrind provided...

+4  A: 

oprofile is pretty good, but it can be difficult to set up. It also doesn't require you to rebuild your program.

George
Yeah... That seems what I need .. But I think it needs root account to set up, right?
superb
Yes, it requires root to set up. Or sudo, depending on how your sudoers file is set up. I'd suggest using a virtual machine, but doing profiling in a VM seems like a bad idea - the bottlenecks when running under a VM may not be the same as when running on a physical machine. I hope you have root on your system.
George
Got it. After read some document about oprofiler I understand that it need kernel to collect some hardware counter so it can profiling the program fast, thus a root privilege is needed to configure. It may not be easy to got root access since I was using a public machine and profiling will impact the performance of that machine. So I think Valgrind maybe the best option ...
superb
+1  A: 

A nicer option than oprofile is Zoom. It's similar to Shark on Mac OS X, if you have ever used that. It's commercial ($199) but you can get a free trial from www.rotateright.com.

Paul R
+1  A: 

Agreeing with Paul, I think Zoom is probably the best Linux profiler you can pay for.

However, for real results, I rely on this simple method, that I've been using since before profilers were invented.

Mike Dunlavey
A: 

Performance Counters for Linux is a new tool usable on kernels 2.6.31 and later; it's less intrusive (to both the program and the system as a whole) than valgrind or OProfile.

ephemient