我是 gprof 的新手,这是我的程序,
#include<stdio.h>
int somefunc(int n)
{
int i,j;
for(i=1;i<=n;i++){
for(j=1;j<=i;j++){
printf("%d\t",j);
}
printf("\n");
}
}
int somefunc1(int n)
{
int i,j;
for(i=n;i>=1;i--){
for(j=i;j>=1;j--){
printf("%d\t",j);
}
printf("\n");
}
}
int main()
{
printf("Hello\n");
int n;
printf("enter n value\n");
scanf("%d",&n);
somefunc(n);
printf("another\n\n");
somefunc1(n);
printf("another\n") ;
}
我试过这个,
gcc -pg program.c
./a.out
gprof a.out gmon.out
它不是显示时间,即即使花费超过 20 分钟,它也显示 0.0% 的时间?输出是这样的,
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 1 0.00 0.00 somefunc
0.00 0.00 0.00 1 0.00 0.00 somefunc1