Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 621
  • Last Modified:

gprof accurate?

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
lost_bits1110
Asked:
lost_bits1110
  • 2
1 Solution
 
pjedmondCommented:
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
 
lost_bits1110Author Commented:
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
 
pjedmondCommented:
>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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now