1
我是新來GPROF,這是我的計劃,gprof不顯示時間即使花了20分鐘以上,它也顯示0.0%的時間?
#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
並且不diaplaying時間,也就是說,它是即使花了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
什麼是您的操作系統? GCC版本?你可以做strace的'.a.out'並且在strace輸出中搜索ALRM或'alarm()'嗎? – osgx
程序是否以'return'或'exit()'結束? Gmon.out僅在正常程序退出時寫入,如果程序使用Ctrl-C停止,則不寫入。 – osgx
gcc version 4.1.2 20080704(Red Hat 4.1.2-51) – no1