驭风万里无垠

GCC4.5的profile mode

GCC最近发布了4.5版本,对于C++的支持除了更为丰富的0x特性支持外(参考这里),
还增加了一个新的profile模式(尚处于试验阶段),可以根据程序运行状态给出关于STL使用的一些优化建议。

参看如下的描述:
  • An experimental profile mode has been added. This is an implementation of many C++ standard library constructs with an additional analysis layer that gives performance improvement advice based on recognition of suboptimal usage patterns. For example,

    #include <vector>
    int main()
    {
    std::vector<int> v;
    for (int k = 0; k < 1024; ++k)
    v.insert(v.begin(), k);
    }

    When instrumented via the profile mode, can return suggestions about the initial size and choice of the container used as follows:

    vector-to-list: improvement = 5: call stack = 0x804842c ...
    : advice = change std::vector to std::list
    vector-size: improvement = 3: call stack = 0x804842c ...
    : advice = change initial container size from 0 to 1024

    These constructs can be substituted for the normal libstdc++ constructs on a piecemeal basis, or all existing components can be transformed via the -D_GLIBCXX_PROFILE macro.

这个profile mode的主要作用就是根据代码实际运行状况给出关于STL的使用优化建议。有点遗憾的是,该profile方法是intrusive的,必须添加-D_GLBCXX_PROFILE来重新编译所有的代码。

Profile mode的提出源于09年CGO的一篇paper,作者里边出现了华人的名字(根据拼音来判断);作者地址填的显然是Purdue大学的:
    Dept. of Comput. Sci., Purdue Univ., West。

GCC的Profiler对C++的支持一贯停留在和C同样的水平;由于C++模板机制和OO的存在使得很多时候分析profiling结果的意义被大大削弱。
这个针对STL的profile mode还是很值得期待的。


posted on 2010-05-09 15:16 skyscribe 阅读(953) 评论(0)  编辑 收藏 引用 所属分类: C++LinuxBuild/Construction


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

导航

统计

常用链接

留言簿(3)

随笔分类

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜