I tend to write rather large templated header-only C++ libraries and my users commonly complain about compilation times. After thinking about the matter, it occurred to me t
Clang 9 (and newer) has a -ftime-trace
flag, which makes it output a profiling report as JSON (in addition to an object file).
You can import this file into a profiler that comes with Chrome (chrome://tracing
) to get a nice visualisation:
The bars correspond to headers that had to be parsed, and for each header, specific classes (and probably other constructs) that had to be parsed. It also reports time spent on instantiating specific templates.