不必要的strerror_l调用

时间:2019-03-12 11:44:27

标签: c++ profiling

#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

0 个答案:

没有答案
相关问题