This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Is gprof insane? "no time accumalted"


This will be a relatively long email, so i'll describe the problem first.

i've got two programs, written in c++, one gives me the following output
from gprof:
Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total
 time   seconds   seconds    calls  ns/call  ns/call  name
 50.00      0.01     0.01     2321  4308.49  4308.49
Age::QuantiseTime(void)
 50.00      0.02     0.01       47 212765.96 411598.08  daily_loop(int)

Isnt that Lovely??

The other gives me the following:
Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

  %   cumulative   self              self     total
 time   seconds   seconds    calls  Ts/call  Ts/call  name
  0.00      0.00     0.00   502686     0.00     0.00
Board::IsValidPoint(Point_
st)
  0.00      0.00     0.00   349689     0.00     0.00
Board::IsValidMoveFor(Poin
t_st, int)

Both are compiled on the same system, with EXACTLY the same flags (in the
same order).. and aside from includes within the project, they #include
exactly the same files in the same order and gprof is called in exactly the
same way (with no flags)...

versions (intel, redhat 7.0):
gcc version 2.96 20000731 (Red Hat Linux 7.0)
GNU gprof 2.10.90

i've also tried it on a sun sparc running solaris with identical results...

What I cant understand is why one gives me a time accumulation and another
doesn't (the important part)... having spent a week and a half with the
issue im at a complete loss (not to mention beyond frustrated).. i've seen a
few posts about similar problems, but nothing resulting..

So I started writing a test program (again using the same includes, flags,
etc, which i've pasted at the bottom)

and the result:
Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

Now, there could be something im missing here, but i've tried it without
using return, and no difference, i've tried using exit rather than return,
no difference, i've tried not returning from my functions, no difference,
i've tried non-void and returning a value functions, no difference... It may
be that something in the program below means it doesnt accumlate time cause
it runs to fast, but i've changed the "sleep" to values above the second
range, and still no difference, i've also changed it to use a loop rather
than the sleep function, still no difference... Does anyone have even the
foggiest notion why this would be happening?? i've tried reading the docs
out at http://www.delorie.com/gnu/docs/binutils/gprof_toc.html (as well as
many many others, if i look at the gprof, gcc or g++ man pages again, i'll
go postal and kill everyone i work with), i've tried trawling the mailing
lists and i've gotten nowhere, im slowly going insane without actually
getting anywhere.. ok, well, you get the drift, someone, please put me out
of my missery...

compiled with: g++ -Wall -pg -g3 -c -o proftest proftest.cc (along with a
two stage compiling and linking seperately, as well as a pure C version)
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <signal.h>
#include <time.h>

void functionone();
void functiontwo();

int main()
{
    int i,j;
    for(i=0; i<10; i++) {
        functionone();
        for(j=0; j<10; j++) {
            functionone();
            functiontwo();
        }
    }
    return 0;
}

void functionone()
{
    usleep(100l);
    return;
}

void functiontwo()
{
    usleep(200l);
    return;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]