Solved

gprof accurate?

Posted on 2006-07-20
5
607 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now