[cfe-dev] Measuring compilation performance

Robert Dailey via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 10 07:05:55 PST 2019

I am experiencing, in general, very slow build times. However, I don't
see a way to measure on a per-file basis, the amount of time the
compiler spends compiling code. I think it would be useful to see
statistics on how many times a header file is compiled (collectively,
across all translation units) as well as per-file (H and CPP) how much
time is spent compiling code. This would allow me to find header files
included too often, and possibly fix it by removing includes, forward
declarations, pimpl idiom, etc. Time spent per-file would be nice to
know if, for example, the way I've implemented a template class is
causing long compile times and refactor it to be faster.

Right now I just don't have a way to do this. Are these metrics
inherently provided by clang? And if not, are there external tools to
help diagnose slow compilation? Advice is greatly appreciated.

More information about the cfe-dev mailing list