Connecting Tech Pros Worldwide Forums | Help | Site Map

how much time?

carlosp
Guest
 
Posts: n/a
#1: Sep 5 '08
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
Guest
 
Posts: n/a
#2: Sep 5 '08

re: how much time?


carlosp wrote:
Quote:
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!
>
>
callgrind
kcachegrind
Pascal J. Bourguignon
Guest
 
Posts: n/a
#3: Sep 5 '08

re: how much time?


carlosp <carlospgmat03@gmail.comwrites:
Quote:
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!
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
Guest
 
Posts: n/a
#4: Sep 5 '08

re: how much time?


On Sep 5, 12:02 pm, carlosp <carlospgma...@gmail.comwrote:
Quote:
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!
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.kanze@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
Guest
 
Posts: n/a
#5: Sep 5 '08

re: how much time?




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