我真的想知道不同的例程在我的应用程序中花了多少时间。 我正在使用GCC 3.4.2和Dev-C ++ IDE和gprof进行性能分析。这是开始 结果文件:
扁平资料:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
7.48 0.89 0.89 __gnu_cxx::__exchange_and_add(int volatile*, int)
7.39 1.77 0.88 _Unwind_SjLj_Register
6.22 2.51 0.74 _Unwind_SjLj_Unregister
3.70 2.95 0.44 2425048 0.00 0.00 rt::wctree_node<std::vector<OPT_Inst, std::allocator<OPT_Inst> > >::get(std::string, bool&)
3.28 3.34 0.39 std::string::operator[](unsigned int)
3.11 3.71 0.37 std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()
2.86 4.05 0.34 std::string::_M_mutate(unsigned int, unsigned int, unsigned int)
2.69 4.37 0.32 __gnu_cxx::__atomic_add(int volatile*, int)
2.61 4.68 0.31 38655 0.00 0.00 SPSBase::containerBoxFillSet(double, double, double, double)
有人可以向我解释除rt :: wctree之外的第一个(显然不是由我制作的),它们来自哪里以及它们在程序中的目标是什么?
答案 0 :(得分:1)
这两个_Unwind
看起来像是异常处理。
_M_mutate
似乎表明你正在复制字符串(libstdc ++实现的Copy on Write行为的实现细节),这似乎是由配置文件中字符串析构函数的存在所强调的。
我猜原子操作也来自字符串COW行为,因为内部缓冲区是引用计数。
因此,您的大部分时间都花在复制std::string
上。
编辑:好的,现在看看你的rt::wctree<>::get(std::string, bool&)
。该参数通过复制传递。 2425048次呼叫,2425048份。你为什么不在这里试试const&
?