Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how much time?

0 views
Skip to first unread message

carlosp

unread,
Sep 5, 2008, 6:02:01 AM9/5/08
to
I am aware that this is, technically, not a question about c++ but
surely here someone will now-how-to. I have a program, with lots of
routines, and complicated stuff. I want to optimize it but I don't
want to optimize all the parts, but rather the ones in which it takes
longer. Of course one can put time logs in the program, but there must
be an efficient way on how to do it. If someone can point out a few
keywords or commands in gdb or other linux debugger or something else,
I would be quite pleased. Thanks a lot!


anon

unread,
Sep 5, 2008, 6:45:55 AM9/5/08
to

callgrind
kcachegrind

Pascal J. Bourguignon

unread,
Sep 5, 2008, 8:15:30 AM9/5/08
to
carlosp <carlos...@gmail.com> writes:

Not gdb, but g++ with gprof.

Pass to g++ on of these options:

# Profile Options (to see where time is spent):
# -p --> prof
# -pg --> gprof
# -a --> tcov
# ATTENTION: -a inhibits -fprofile-args!

and possibly one or both of these options:

# Coverage Options (to check coverage of test cases):
# -fprofile-args ==> $@.da
# -ftest-coverage ==> $@.bb, $@.bbg

Then run your program.

Then use gprof to get a profile report, or gcov to get the coverage.

--
__Pascal Bourguignon__

James Kanze

unread,
Sep 5, 2008, 8:40:38 AM9/5/08
to

The tool you're looking for is called a profiler. Under Linux,
there's gprof, which is quite good.

Typically, you'll also have to compile with special options: for
gprof, you'll need -pg with g++, but check the documentation.

--
James Kanze (GABI Software) email:james...@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

carlosp

unread,
Sep 5, 2008, 9:22:18 AM9/5/08
to

Thanks, I will try then gprof which seems to be the tool I am looking
for. Thanks a lot!

0 new messages