Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

gprof accurate?

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Ubuntu Apache Webserver - File Permissions 5 59
The better OS Architecture 13 66
Internal CA server 6 47
Redhat upgrade 1 25
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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.

829 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