[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gprof doesn't display function 'main' in flat profile results
From: |
Michael Pakhomov |
Subject: |
gprof doesn't display function 'main' in flat profile results |
Date: |
Thu, 24 Oct 2002 10:43:30 +0400 |
Hi all,
it's quite interesting for me why gprof doesn't display 'main' function in flat
profile results.
that's what i did:
1. compiled a simple application with -pg key as follows:
g++ -o foo foo.cpp -g -pg
pls see the code of foo.cpp below:
//====================================================================
#include <iostream.h>
// g++ -o foo foo.cpp -g -pg
//===
const int num = 50000;
double eval_sum(int n = 200);
//====
void f1()
{
eval_sum();
}
void f2_call_f1()
{
eval_sum();
f1();
}
void f3()
{
eval_sum();
}
double eval_sum(int n/* = 200*/){
double sum = 0.0, fact = 1.0;
int i, j; // loop
// direct order
for (i = 1; i <= n; ++i){
fact *= (i + 1);
sum += 1.0 / fact;
}
// reset sum
sum = 0.0;
// indirect order
for (i = n; i >= 1; --i){
fact = 1.0;
for (j = 1; j < i + 1; ++j){
fact *= (j + 1);
}
sum += 1.0 / fact;
}
return sum;
}
int main (void)
{
cout << "start->..." << endl;
int i, step;
for (i = 0, step = num / 10; i < num; ++i) {
// progress bar
if ((i % step) == 0) {
cout << "*" << flush;
}
f1();
f2_call_f1();
f3();
}
cout << endl << "finish->..." << endl;
return 0;
}
//====================================================================
2. ran foo
3. execute 'gprof -p -b foo' and got the following output:
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls us/call us/call name
100.00 111.09 111.09 200000 555.45 555.45 eval_sum(int)
0.00 111.09 0.00 100000 0.00 555.45 f1(void)
0.00 111.09 0.00 50000 0.00 1110.90 f2_call_f1(void)
0.00 111.09 0.00 50000 0.00 555.45 f3(void)
where is function 'main'? gprof doesn't display it in flat profile results, but
display it in the call graph. than i ran gprof on another applications and
found out that for some of them gprof displays 'main' and for some of them not.
i read documentation on gprof, looked in gcc/binutils maillists archive, but
haven't found the answer.
did i miss something? can somebody kindly help me?
my platform is a p4 running red hat 7.3
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110)
binutils-2.11.93.0.2-11
glibc-2.2.5-34
P.S. initialy i mixed up maillists and sent out this e-mail to address@hidden
now i hope i'm sending my report to correct people ;-)
thanks in advance
cheers
/mpakhomo
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gprof doesn't display function 'main' in flat profile results,
Michael Pakhomov <=