c++ - 不必要的 strerror_l 调用
问题描述
#include <iostream>
int main(){
for(int i = 0; i < 100000000; i++){
std::string from = "hello";
}
return 0;
}
此代码在 std::string 构造函数内产生一些 strerror_l 调用。它是示例代码,在实际项目中调用了更多次(使用 google pprof 进行分析)。它是什么,我怎样才能避免这些电话?
测试环境:
debian 6.0.1, g++ 4.4.5 and g++ 4.9.2
- 没有 strerror_l 调用
debian 8.6, g++ 4.9.2
- 几个电话
重现方式(需要google pprof):
使用探查器构建:
g++ question.cpp -lprofiler
获取个人资料数据:CPUPROFILE=/tmp/question.out /tmp/a.out
构建调用图:google-pprof --pdf /tmp/a.out question.out > output.pdf
解决方案
推荐阅读
- javascript - JQuery append() 信息即使在硬刷新后仍然存在
- agile - 如何管理需要多个 Sprint 的用户故事
- javascript - 在页面内注入书签后,$ 不是函数错误
- javascript - 从 JavaScript 中的另一个函数访问一个函数内部的 var
- python-3.x - 查找列表中的任何值是否存在于数据框中的任何位置
- python - 在熊猫数据框中处理不一致的数据
- python - Pandas Grouper 计算事件之间经过的时间
- swift - 问题过滤带有部分的 Swift UITableView - 未显示结果
- c - 请求重放模式中的 ZeroMQ 只允许来自特定 IP 的请求
- python - AttributeError:“datetime.timedelta”对象没有属性“strftime”