gcc -ftime-report provides a breakdown of how much time GCC spends
doing preprocessing, parsing, template instantiation, and more:
g++ -ftime-report foo.cpp Execution times (seconds) phase setup : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.00 ( 0%) wall 1414 kB ( 8%) ggc phase parsing : 0.10 (100%) usr 0.08 (100%) sys 0.18 (95%) wall 15955 kB (88%) ggc phase opt and generate : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.01 ( 5%) wall 489 kB ( 3%) ggc |name lookup : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.04 (21%) wall 1054 kB ( 6%) ggc preprocessing : 0.02 (20%) usr 0.01 (13%) sys 0.03 (16%) wall 896 kB ( 5%) ggc parser (global) : 0.00 ( 0%) usr 0.03 (38%) sys 0.04 (21%) wall 6603 kB (37%) ggc parser struct body : 0.04 (40%) usr 0.00 ( 0%) sys 0.04 (21%) wall 2791 kB (15%) ggc parser enumerator list : 0.01 (10%) usr 0.00 ( 0%) sys 0.00 ( 0%) wall 44 kB ( 0%) ggc parser function body : 0.00 ( 0%) usr 0.02 (25%) sys 0.02 (11%) wall 1047 kB ( 6%) ggc parser inl. meth. body : 0.01 (10%) usr 0.01 (13%) sys 0.03 (16%) wall 1093 kB ( 6%) ggc template instantiation : 0.02 (20%) usr 0.01 (12%) sys 0.02 (11%) wall 3280 kB (18%) ggc LRA non-specific : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.01 ( 5%) wall 0 kB ( 0%) ggc TOTAL : 0.10 0.08 0.19 18028 kB
clang -ftime-report gives an incredibly detailed breakdown of how long
each LLVM pass takes, but when it comes to front-end times, only
provides the generic "Clang front-end timer", or "Code Generation Time".
Here's an example of its output:
https://gist.github.com/modocache/d74833818107ed50d11387a5a4e3fb72
As a result, when attempting to diagnose slow compile times with Clang,
users are forced to use external profiling tools in order to determine
whether the bottleneck is in parsing, template instantiation, or LLVM.
This diff adds the first of several timers that aim to match
gcc -ftime-report: a timer that outputs the amount of time spent in the Clang
preprocessor.
Should this be named "Lexing Time" or "Lexing" instead of "Preprocessing"?