473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

how much time?

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!
Sep 5 '08 #1
4 1238
carlosp wrote:
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
Sep 5 '08 #2
carlosp <ca***********@gmail.comwrites:
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__
Sep 5 '08 #3
On Sep 5, 12:02 pm, carlosp <carlospgma...@gmail.comwrote:
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:ja*********@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
Sep 5 '08 #4


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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Bart Nessux | last post by:
am I doing this wrong: print (time.time() / 60) / 60 #time.time has been running for many hours if time.time() was (21600/60) then that would equal 360/60 which would be 6, but I'm not getting...
5
by: David Stockwell | last post by:
I'm sure this has been asked before, but I wasn't able to find it. First off I know u can't change a tuple but if I wanted to increment a time tuple by one day what is the standard method to do...
6
by: David Graham | last post by:
Hi I have asked this question in alt.php as the time() function as used in setcookie belongs to php - or does it belong equally in the javascript camp - bit confused about that. Anyway, can anyone...
3
by: Szabolcs Nagy | last post by:
I have to measure the time of a while loop, but with time.clock i always get 0.0s, although python manual sais: "this is the function to use for benchmarking Python or timing algorithms" So i...
6
by: Rebecca Smith | last post by:
Today’s question involves two time text boxes each set to a different time zone. Initially txtCurrentTime will be set to Pacific Time or system time. This will change with system time as we travel...
3
by: luscus | last post by:
Thanks for all the responses on my first question. Unfortunately the answers I was given were too complicated for my small brain , and neophite condition to understand. So if you could talk down to...
3
by: cj | last post by:
If I want to check to see if it's after "11:36 pm" what would I write? I'm sure it's easy but I'm getting tired of having to work with dates and times. Sometimes I just want time or date. And...
1
by: davelist | last post by:
I'm guessing there is an easy way to do this but I keep going around in circles in the documentation. I have a time stamp that looks like this (corresponding to UTC time): start_time =...
2
by: Roseanne | last post by:
We are experiencing very slow response time in our web app. We run IIS 6 - windows 2003. I ran iisstate. Here's what I got. Any ideas?? Opened log file 'F:\iisstate\output\IISState-812.log'...
9
by: Ron Adam | last post by:
I'm having some cross platform issues with timing loops. It seems time.time is better for some computers/platforms and time.clock others, but it's not always clear which, so I came up with the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.