我的gprof输出中的这些c ++ std函数需要花费很多时间?

问题描述 投票:1回答:1

Gprof输出。我在代码中使用了双端队列,向量和std ::移动。

Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls   s/call   s/call  name    
 10.70      0.78     0.78 411724776     0.00     0.00  __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >::operator*() const
  5.97      1.22     0.44 114087996     0.00     0.00  __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >::operator--()
  5.90      1.65     0.43 256602502     0.00     0.00  __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >::base() const
  5.90      2.08     0.43 197352626     0.00     0.00  std::remove_reference<int&>::type&& std::move<int&>(int&)
  5.76      2.50     0.42    20556     0.00     0.00  void std::__move_merge_adaptive<int*, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__ops::_Iter_less_iter>(int*, int*, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__ops::_Iter_less_iter)
  5.49      2.90     0.40 139505351     0.00     0.00  __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >::operator++()
c++11 vector profiling gprof
1个回答
0
投票

这些是标准库的实现细节。由于要进行概要分析,因此要在编译器中启用优化功能,否则编译器基本上不会注意试图使程序快速运行,而只是在尝试使其易于调试。启用优化后,随着编译器意识到可以内联这些函数,它们应该消失,从而消除了函数调用开销。

© www.soinside.com 2019 - 2024. All rights reserved.