Thread: Profiler Problems

  1. #1
    Registered User
    Join Date
    Feb 2004
    Posts
    15

    Profiler Problems

    I'm using gprof to profile my program. I run the program and produce the file gmon.out, which I interpret with gprof. The result is a text file with my profile data in. However, while there is data in this file pertaining to the number of function calls, function names, etc, all of the time data is zero. Can anyone suggest why this is indeed the case?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    The timers have a granularity, which is greater than what it takes to execute very short functions.

    Isn't that in the gprof FAQ?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Feb 2004
    Posts
    15
    There's the online documentation, although I can't find any relevant information in that. Perhaps I'm looking in the wrong places, or perhaps it's not there...

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Odd, this sticks out like a sore thumb.
    http://www.gnu.org/software/binutils...rof.html#SEC19
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Feb 2004
    Posts
    15
    Yes, I looked there, but what I'm saying is that I can't find the information I need in that documentation...

    I just found this in my file, which corroborates your idea:
    granularity: each sample hit covers 4 byte(s) no time accumulated
    I searched for granularity in the documentation, but I didn't find any info regarding how to change it. Any ideas?

  6. #6
    Registered User
    Join Date
    Feb 2004
    Posts
    15
    I think I may have found the reason for the empty data file... It seems that most of the runtime is due to system overhead, although I don't know why this is so. I don't write/read from files much or issue any explicit system() commands. Could it be due to overtaxing the RAM?

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    I'm getting bored of reading the manual for you
    Quote Originally Posted by gprof
    This is done is one of two ways. Most UNIX-like operating systems provide a profil() system call, which registers a memory array with the kernel, along with a scale factor that determines how the program's address space maps into the array. Typical scaling values cause every 2 to 8 bytes of address space to map into a single array slot. On every tick of the system clock (assuming the profiled program is running), the value of the program counter is examined and the corresponding slot in the memory array is incremented. Since this is done in the kernel, which had to interrupt the process anyway to handle the clock interrupt, very little additional system overhead is required.
    So the first answer is "not without serious kernel or gprof hacking".

    As for your other question, I've no idea what "overtaxed RAM" is, unless your "ISR" has been replaced by an "IRS".

    Maybe post some code if you want a better explained answer.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Feb 2004
    Posts
    15
    Thanks for the info, Salem. The code is several thousand lines and I have no idea where in the code the problem is (as that's what I was using the profiler for), so I can't post any code, unfortunately. Back to the drawing board...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 06:35 AM
  3. Rendering problems (DirectX?)
    By OnionKnight in forum Tech Board
    Replies: 0
    Last Post: 08-17-2006, 12:17 PM
  4. contest problems on my site
    By DavidP in forum Contests Board
    Replies: 4
    Last Post: 01-10-2004, 09:19 PM
  5. DJGPP problems
    By stormswift in forum C Programming
    Replies: 2
    Last Post: 02-26-2002, 04:35 PM