Solved

gprof accurate?

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AWS CLI - Issue with name display 2 73
Setting up two Raspberry Pi gateways/routers 3 65
wipe a usb using python 5 48
Setting up static IP - Ubuntu server 16.04 12 65
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

821 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