简体   繁体   中英

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?

如果您使用采样分析器 (例如ZoomShark ),而不是仪表化的分析器 (例如gprof),那么您可以获得更精细的粒度分析,直到语句和指令级别。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM