gprof: time not counted

This is a discussion on gprof: time not counted within the C++ Programming forums, part of the General Programming Boards category; I want to use gprof to optimize my program. But in its output, time is not counted for any function. ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    10

    gprof: time not counted

    I want to use gprof to optimize my program. But in its output, time is not counted for any function. All the entries for time are 0.0 . My program runs for 50s. My operating system is Mac OSX. I used
    g++ -g -pg -o execname cppfiles.... to compile. How should I solve it? Thanks!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    So do you actually run gprof when your program exits? You also need to do this step as well.

    Does your program achieve a normal exit, or is it failing in some way?
    Do you see a gmon.out file in the current directory (it's where profile data is written to when the program exits).
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    10
    Quote Originally Posted by Salem View Post
    So do you actually run gprof when your program exits? You also need to do this step as well.
    I think so. I did
    ./execname
    gprof execname

    Quote Originally Posted by Salem View Post
    Does your program achieve a normal exit, or is it failing in some way?
    It achieved a normal exit.

    Quote Originally Posted by Salem View Post
    Do you see a gmon.out file in the current directory (it's where profile data is written to when the program exits).
    Yes, I saw the gmon.out. I can see other all the information, like how many times a function is called, just the time is always 0.

    Thanks!

  4. #4
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    What do the functions do? Are they using 100% CPU? Or just sleeping?

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about Gprof
    By PetrolMan in forum C++ Programming
    Replies: 1
    Last Post: 03-23-2009, 10:18 AM
  2. Gprof under windows
    By Kempelen in forum C Programming
    Replies: 7
    Last Post: 05-23-2008, 05:49 PM
  3. Profiling with GPROF
    By RoshanX in forum C Programming
    Replies: 2
    Last Post: 03-30-2007, 02:38 PM
  4. A Generic Reference-Counted Pointer Class (4 Bubba)
    By Codeplug in forum C++ Programming
    Replies: 46
    Last Post: 12-19-2004, 03:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21