Solved

gprof accurate?

Posted on 2006-07-20
5
613 Views
Last Modified: 2006-11-18
Hi there,

I'm doing graphics programming with C++, OpenGL and the VTK library on Fedora.  
I'm using gprof to try and figure out the bottleneck in my code. I'd also like to get precise timing information using this tool.

One concern is that when I timed the program myself, it ran for about 90 to 100 seconds max. When I profiled this same execution using gprof, it tells me that it ran for about twice this amount! (i.e. it says "granularity: each sample hit covers 4 byte(s) for 0.01% of 181.68 seconds".

This makes me concerned about the accuracy of gprof, or hopefully I'm just doing something wrong?
Thanks very much for your assistance!!!
0
Comment
Question by:lost_bits1110
  • 2
5 Comments
 
LVL 22

Expert Comment

by:pjedmond
ID: 17156042
I'm presuming that the 181 seconds includes running the gprof code as well as the code that is being profiled?

Overall, even if the absolute accuracy is not 100% accurate, comparitive amounts of time spend in various locations are. As you're trying to work out where bottlenecks are, gprof provides a very good indication of where these are.

(   (()
(`-' _\
 ''  ''
0
 

Author Comment

by:lost_bits1110
ID: 17159112
Hi pjedmond,

Thanks for your response,

What do you mean by "..includes running the gprof code..". Do you mean that its including the time it takes to generate the gprof output file, i.e when I do "gprof execfile > output-file" for example?

It seems strange that this would be included in the timing, I thought it would just include the time to run my code being profiled?

I realize that the relative timings must be accurate, but I need for the actual numbers to be somewhat accurate since I'm just trying to do some calculations with them. The fact that it reported ~180 seconds when I manually timed it to be ~90 seconds seems is a huge difference, so it just worries me..
0
 
LVL 22

Accepted Solution

by:
pjedmond earned 75 total points
ID: 17159368
>What do you mean by"..includes running the gprof code.."

My understanding is that it sets an interupt/trace bit in some way to ensure that the code being profiled is 'interupted and profiling can take place'.

If a trace is set, then pententially after every command, there will be a 'jmp' to  a vector. It will not be in the gprof code until the 'jump' to a vector is complete. I'm wondering if in some way this 'extra' command per execfile command is being included.

As for 'absolute timings', these will depend on the system load at the time, and also a number of other factors, so only the 'relative' values are the only figures of any real value. If you need absolute figures in a particular scenario, then I'd probably use gettimeofday() in the code, and work out the change between 2 points. Obviously bear in mind the implications of scheduling.

(   (()
(`-' _\
 ''  ''


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question