Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I profile code beyond per-function level?

AFAIK profilers can only tell how much time is spent in each function. But since C++ compilers tend to inline code aggressively and also some functions are not that short it's often useful to know more details - how much time each construct consumes.

How can this be achieved except restructuring code into smaller functions?

like image 232
sharptooth Avatar asked Dec 03 '10 10:12

sharptooth


2 Answers

If you use a sampling profiler (e.g. Zoom or Shark), rather than an instrumented profiler (e.g. gprof) then you can get much finer grained profiles, down to the statement and instruction level.

like image 56
Paul R Avatar answered Nov 07 '22 05:11

Paul R


If you can use callgrind then you can get a summary of which methods are taking most of the processing time. Then you can use kcachegrind to view the results. It gives a very nice graph, through which you can easily browse and find bottlenecks.

like image 43
BЈовић Avatar answered Nov 07 '22 06:11

BЈовић