Issue
I'm creating a fairly large library in C++0x using GCC 4.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.
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?
Solution
g++ some_file.cc -ftime-report will give you a rough estimate of time spent in different compiler phases. The most important ones in your case are name lookup and parsing.
There isn’t any way to get a per class/function compile time alas.
Steven Watanabe has proposed a template profiler, available in the Boost sandbox that helps getting the number of potential instantiation of anything in a .cc file.
Answered By - Joel Falcou Answer Checked By - Cary Denson (WPSolving Admin)