sharptooth
sharptooth

Reputation: 170489

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?

Upvotes: 6

Views: 459

Answers (2)

BЈовић
BЈовић

Reputation: 64213

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.

Upvotes: 2

Paul R
Paul R

Reputation: 212949

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.

Upvotes: 5

Related Questions