协助C++程序评测
Assistance with C++ program profiling
我真的很想知道不同的例程在我的应用程序中需要多少时间。我使用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(显然不是我做的)之外的第一个吗?它们来自哪里?它们在程序中的目标是什么?
两个_Unwind
在我看来像是异常处理。
_M_mutate
似乎表明您正在复制字符串(libstdc++实现的"写时复制"行为的实现细节),配置文件中的字符串析构函数似乎给它加了下划线。
我想原子操作也来自字符串COW行为,因为内部缓冲区是引用计数的。
所以你的大部分时间似乎都花在了复制std::string
上。
编辑:好的,现在看看您的rt::wctree<>::get(std::string, bool&)
。参数是通过副本传递的。2425048个电话,2425048份复印件。你为什么不试试const&
呢?
相关文章:
- Mongodb c++驱动程序:如何查询元素的数组
- C++,系统无法执行指定的程序
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- C++ Windows 驱动程序MSB3030无法复制该文件,因为它找不到
- 重载操作程序时出错>>用于类中的字符串 memebr
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- 试图在visual studio上用C++创建一个桌面应用程序
- 模板元程序查找相似的连续类型名称
- FFmpeg:制作一个应用程序比直接使用ffmepg更好吗
- 如何通过cpp程序运行shell脚本
- 有没有什么方法可以使用一个函数中定义的常量变量,也可以由c++中同一程序中的其他函数使用
- IPC使用多个管道和分支进程来运行Python程序
- 如何将c++程序的一些输出传递给shell,以便在shell中使用
- 使用C++程序合并排序没有得到正确的输出
- 基于boost的程序的静态链接——zlib问题
- 程序崩溃并显示"std::out_of_range"错误
- 在C应用程序中运行C++(带有STL)函数
- 协助C++程序评测
- 使用库对基于g++的应用程序进行c++评测