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

StackOverflow https://stackoverflow.com/questions/18955839

  •  29-06-2022
  •  | 
  •  

Question

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
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top