0

I am aware there's a frequency of sample counts in gprof before it prints the flat profile. Based on the frequency of sample counts, my judgement would be longer the program runs, more is the sample collected for profiling and hence better is the data. But I am not really sure if this is true and whether long running programs are suitable for being profiled on gprof.

Any inputs will be really helpful.

ggulgulia
  • 2,720
  • 21
  • 31
  • When you say "analysis", what *gprof* tells you is there's not much you could do to speed up the program, which is likely to be good news to the programmer - *false* good news. [*Here's why, and how to do it better.*](https://stackoverflow.com/a/1779343/23771) – Mike Dunlavey Nov 16 '17 at 20:51
  • i am not concerned with speed up of the program, just the veracity of the results of gprof for programs that run for long time – ggulgulia Nov 17 '17 at 21:21

2 Answers2

1

true, gprof has advantages (availability in any platform) the disadvantages however make him unsuitable for more complex programs. 1)instrumentation adds function call overhead 2)cant profile code in shared libraries 3)profiles only the main thread 4)doesnt provide information about cache misses 5)doesnt give flops/s 6)doesnt analyse loops etc

john
  • 373
  • 1
  • 16
0

My answer that seems by far the most logical to me is :

If the program is long running and we are only interested in profiling, then grpof seems a suitable tool because gprof relies on frequency of sample collection, which by default is 100 Hz. If the running time of gprof is very small and if within this small duration it calls many functions, then it is highly likely that the samples size for profiling are very less and hence the samples of profiled functions are not reliable. Otherwise the instrumentation overhead for profiling can increase the run time of a program and the total execution time may not reflect the actual runtime of an application, which can simply be measured by the calling the suitable time functions provided by operating system kernel.

ggulgulia
  • 2,720
  • 21
  • 31