简体   繁体   English

构建分析:CMake/ninja 可以为每个编译单元生成编译时间日志吗?

[英]Build profiling: Can CMake/ninja produce a log of compile time for each compilation unit?

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.这似乎应该很容易......如果我在一个文件中列出了每个clang命令,我可以对每个命令计时并按时间排序以找到耗时最长的编译,然后我可以 go 并查看其中哪些编译单元令人惊讶,并试图弄清楚它们为什么这么慢。

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?如何让 CMake/ninja 转储它想要运行的所有clang命令的列表?
  • 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 ?或者,也许这样做的方法是编写一个脚本来记录命令和它所花费的时间并将其用作CXX_COMPILER_LAUNCHER

To get the list of compile commands use compile_commands.json .要获取编译命令列表,请使用compile_commands.json

Try using ninjatracing tool for getting build profile in Chrome's about:tracing format.尝试使用ninjatracing工具以 Chrome 的 about:tracing 格式获取构建配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM