Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何像 Matlab 中的 profile 工具那样对 c++ 代码进行剖析以获取每行代码的调用时间和花费时间?
我尝试使用-fprofile-arcs之类的东西,但它只生成一个代码覆盖率报告,其中可以找到调用时间,但不能找到成本时间。
有人可以帮忙吗?问候。
g++ -pg您可以使用(或者-p可能甚至--coverage; 并且-Wall总是有帮助)进行编译,然后使用gprof(甚至gcov)。你可以学习使用oprofile; 阅读有关 GCC调试选项的更多信息
g++ -pg
-p
--coverage
-Wall
gprof
gcov
oprofile