1

I have a simple C program as follows

main(int argc, char *argv[])
{
    /* Calling read function to character device driver*/
    int fd = fopen("MyCharDevice",0);

    /*write call to device and further code*/
    return 0;
}

Now when I am profiling it using gprof, i'm not getting the time for the main() function itself.

$ gprof -b -a a.out > analysis.txt

Where i'm calling my char device (whose profiling i need to do). I tried putting code corresponding to calling device driver in some other function but i get same thing.

Contents of analysis.txt are as follows :

Flat profile:

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        3     0.00     0.00  __gmon_start__

            Call graph


granularity: each sample hit covers 4 byte(s) no time propagated

index % time    self  children    called     name
                0.00    0.00       3/3           main [3]
[4]      0.0    0.00    0.00       3         __gmon_start__ [4]
-----------------------------------------------

Index by function name

   [4] __gmon_start__

I am not getting how can i get the time.

My requirement :
Actually I have to compare semaphore and R/W Semaphore performance using some Linux performance analysis tools. So i'm using gprof.

TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130
Pravesh Gupta
  • 101
  • 2
  • 10

1 Answers1

0

I'm a stuck record, repeating over and over

gprof is blind to I/O time
gprof is blind to I/O time
gprof is blind to I/O time
etc. etc.

and the way to tell how time is spent is put a loop around it and

pause it under GDB and examine the stack
pause it under GDB and examine the stack
pause it under GDB and examine the stack
etc. etc.

for all these reasons, and good luck!

Community
  • 1
  • 1
Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135