调试GCC编译时间 [英] Debugging GCC Compile Times
问题描述
我在C ++(0X)中使用gcc4.6在linux中创建了一个相当大的库。我的库很大程度上依赖于模板类,导致使用库的应用程序的编译时间较长。我想通过提供明显的实例化的最坏的冒犯类型/方法开始加速的事情。
I'm creating a fairly large library in C++(0X) using gcc4.6 in linux. My library relies heavily on template classes, resulting in long compile times for applications which use the library. I would like to start speeding things up by providing explicit instantiations of the worst offending types/methods.
有没有办法让gcc报告编译各种类型/方法所花费的时间,以便我可以以原则的方式而不是通过直觉应用我的显式实例化?
Is there a way to have gcc report the time spent compiling various types/methods so that I can apply my explicit instantiations in a principled way, rather than through intuition?
推荐答案
g ++ some_file.cc -ftime-report
g++ some_file.cc -ftime-report
你粗略估计在不同编译器阶段花费的时间。在您的案例中最重要的是名称查找和解析。
will give you a rough estimate of time spent in different compiler phase. Most important ones in your case are name lookup and parsing.
没有办法获得每个类/函数编译时间alas。
No way to get a per class/function compile time alas.
STeven Watanabe提出了一个模板剖析器,可在boost沙箱中使用,它可帮助获取.cc中潜在实例化的数量
STeven Watanabe has proposed a template profiler , available in boost sandbox that helps getting the number of potential instantiation of anything in a .cc
这篇关于调试GCC编译时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!