gprof not displaying time i e it is displaying 0.0% time even if it is taking more than 20 min?

旧城冷巷雨未停 提交于 2019-12-11 09:18:37

问题


I am new to gprof, this is my program,

 #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") ;
}

and i tried this,

gcc -pg program.c
./a.out
gprof a.out gmon.out

and it is not diaplaying time, i e it is displaying 0.0% time even if it is taking more than 20 min? output is like this,

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

回答1:


gprof does not sample during I/O or other non-process time.

Since your program does practically nothing besides I/O, gprof is showing you practically nothing.

See this.



来源:https://stackoverflow.com/questions/18955839/gprof-not-displaying-time-i-e-it-is-displaying-0-0-time-even-if-it-is-taking-mo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!