Build profiling: Can CMake/ninja produce a log of compile time for each compilation unit?
Asked Answered
F

1

9

I'm trying to profile the build time of my project so I can see what's taking the most time. This seems like it should be easy... if I had every clang command listed in a file I could time each one of them and sort by time to find the compilations that take the longest, then I could go in and see which of those compilation units are surprising and try to figure out why they are so slow.

Googling gets me nowhere on this. Clearly this is possible and would be useful.

So, either:

  • What's the option to basically do this?

or

  • How do I get CMake/ninja to dump out the list of all clang commands it wants to run?
  • Alternately, maybe the way to do it is to write a script that logs the command and time it took and use that as a CXX_COMPILER_LAUNCHER?
Ferrite answered 1/12, 2020 at 21:2 Comment(0)
G
4

To get the list of compile commands use compile_commands.json.

Try using ninjatracing tool for getting build profile in Chrome's about:tracing format.

Gonfanon answered 5/5, 2021 at 15:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.