gpt4 book ai didi

c++ - 使用 解释 gprof 输出

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:41:47 25 4
gpt4 key购买 nike

我试图在我的程序中找到性能问题,因此通过分析来检测代码。 gprof 创建一个像这样的平面配置文件:

Flat profile:

Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
27.97 4.10 4.10 std::_Deque_iterator<char, char&, char*>::_Deque_iterator(std::_Deque_iterator<char, char&, char*> const&)
6.96 5.12 1.02 std::_Deque_iterator<char, char&, char*>::difference_type std::operator-<char, char&, char*>(std::_Deque_iterator<char, char&, char*> const&, std::_Deque_iterator<char, char&, char*> const&)
5.12 5.87 0.75 std::__deque_buf_size(unsigned int)
4.23 6.49 0.62 std::_Deque_iterator<char, char&, char*>::operator+=(int)
3.41 6.99 0.50 std::deque<char, std::allocator<char> >::begin()
1.91 7.27 0.28 7896 0.04 0.04 std::vector<MyClass, std::allocator<MyClass> >::_M_insert_aux(__gnu_cxx::__normal_iterator<MyClass*, std::vector<MyClass, MyClasst> > >, MyClassconst&)
1.91 7.55 0.28 std::deque<char, std::allocator<char> >::size() const
1.91 7.83 0.28 std::_Deque_iterator<char, char&, char*>::_S_buffer_size()

紧随其后的是许多行,时间更短。

第一个问题:相信 std::deque 似乎存在问题是否是一个有效的假设?问题是:我知道我们正在使用 std::deque,但我不知道 <char> 的用法.

如果这个假设成立,那么查看调用堆栈并查看使用此双端队列的位置似乎是有意义的。然而所有关于 deque<char> 的条目东西只被 <spontaneous> 调用!

举个例子:

index % time    self  children    called     name
<spontaneous>
[1] 28.0 4.10 0.00 std::_Deque_iterator<char, char&, char*>::_Deque_iterator(std::_Deque_iterator<char, char&, char*> const&) [1]

有什么办法可以找到更多关于这个双端队列的信息吗?

感谢任何提示!

最佳答案

显然,自发是 gprof 在无法计算出调用函数时使用的方法。我会尝试使用 -pg 重新编译所有代码(您是否可能遗漏了一些文件?)。另外,请确保您已打开优化。内联通常会使这些小函数消失在通常更有用的调用函数中。

关于c++ - 使用 <spontaneous> 解释 gprof 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7606408/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com