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
.