profiling C code

I am trying to generate profiling (line by line of source code) for my code for which I have used gperftools.

gcc a.c -lprofiler -Wl,--no-as-needed -lprofiler -Wl,--as-needed

CPUPROFILE=out.ptof ./a.out 

But

pprof  ./a.out out.ptof --inuse_objects --lines --heapcheck  --edgefraction=1e-10 --nodefraction=1e-10 --gv
Using local file ./a.out.
Using local file out.ptof.
No nodes to print

Why pprof states "No nodes to print"?


It seems that there might be several reasons.

Quoting the most likely (assuming your code is light):

If you see a message like "No nodes to print" [...] it simply means that the code was so fast that it couldn't be profiled - basically, the profiler never even had a chance to take a sample.

And:

In the default mode, there will be no profiling data for the 'slow' route, because it uses few CPU cycles (You'll see the message 'No nodes to print').

So you might need to artificially slow down your program...

链接地址: http://www.djcxy.com/p/87954.html

上一篇: Gperftools如何在引擎盖下工作?

下一篇: 剖析C代码