Interpreting gprof result and granularity

1.5k Views Asked by At

I am using gprof for profiling a C program for the first time. The following lines appears in the report that I generated using;

 $  gprof test_gprof gmon.out > analysis.txt

In Flat Profile

Each sample counts as 0.01 seconds.

is this the maximum resolution in time?

In call graph:

granularity: each sample hit covers 4 byte(s) for 7.69% of 0.13 seconds

What exactly is 4 bytes here ? and what time it is talking about?

1

There are 1 best solutions below

0
On

Please read charpter 5.1 and 5.2 of this manual. You can also read this manual on CentOS with the following command:

$ info gprof

In Flat Profile,

Each sample counts as 0.01 seconds.

indicates that the sampling period is 100Hz, which is not controlled by gprof itself(Check this page and this one for more details). Therefore, 0.01 seconds is theoretically not the maximum resolution in time.

As for Call graph, according to this doc from Oracle,

The "4 bytes" means resolution to a single instruction. The "0.07% of 14.74 seconds" means that each sample, representing ten milliseconds of CPU time, accounts for 0.07% of the run.