Łukasz Lew
Łukasz Lew

Reputation: 50248

What free, low-overhead (statistical) profilers one can use under Linux?

Preferably from Ubuntu repositories.

Upvotes: 2

Views: 1514

Answers (5)

Mike Dunlavey
Mike Dunlavey

Reputation: 40659

A simple but effective technique is to run the program under GDB and handle the SIGINT signal. While the program is running, generate SIGINT manually by typing control-c or whatever, and while it is halted, record the call stack. Do this a number of times, like 10 or 20, while the program is being subjectively slow. This will give you a very good idea of where the time goes.

This method does not give you precise timing, but it does precisely locate the instructions, including call instructions, that cost the most time.

How can I profile C++ code running in Linux?

Upvotes: 2

codelogic
codelogic

Reputation: 73622

Sysprof is a good profiler, similar to OProfile (also has a gtk GUI). which is available in the Ubuntu repository. It's a kernel level profiler, requiring a kernel module unlike gprof, however, also unlike gprof, it can profile multithreaded applications.

Upvotes: 1

Charles Duffy
Charles Duffy

Reputation: 295353

Others have mentioned OProfile; for full-system statistical profiling on modern Linux installations, it does indeed rock.

The more venerable tool (which doesn't require kernel support and thus will work under older versions of Linux or even non-Linux operating systems) is GNU gprof, included in binutils (and thus doubtless already installed in your development environment).

To use gprof, just compile your application with the -pg argument to gcc; a file called gmon.out will be created after your program exits, and gprof can then be used to analyze this file.

Upvotes: 3

jasedit
jasedit

Reputation: 662

I've had good success with oprofile (http://oprofile.sourceforge.net/news/) which is available in Ubuntu repositories as well. It doesn't require recompilation, and doesn't have any limitations regarding shared objects or the like.

Upvotes: 0

Łukasz Lew
Łukasz Lew

Reputation: 50248

There is OProfile. It is not that difficult to use, but is somewhat buggy.

Upvotes: 0

Related Questions