如何测量 scons 构建的每个组件的构建时间?
我有一个使用 scons 构建的大型 C++ 项目。 它的构建速度很慢,我想进行一些更改以使其构建速度更快。 现在我想集中时间加速构建中最慢的部分。
如何找出哪些文件的编译时间最长?
I have a big C++ project that is built using scons.
Its building slow and I want to make some changes to try to make it build faster.
Now I'd like to focus my time speeding up the parts of the build that are slowest.
How can I work out which files are taking the longest to compile?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我知道这个问题很旧,并且已经被接受,但最近从另一个问题中引用了它。我认为一个更优雅的解决方案是使用 SCons
--debug=time
命令行选项,如I know this question is old, and has already been accepted, but it was recently referenced from another question. I think a much more elegant solution would be to use the SCons
--debug=time
command line option, as mentioned in this answer.如果您使用的是 LInux,则可以包装
gcc
或g++
,以便编译器的调用使用gtime
实用程序。对编译器的每次调用都类似于:BASH 有一些神奇的语法,可以帮助您避免必须重新转义你的参数:
然后将你的 $PATH 变量指向你的编译器包装器。
然后通过选项
-j1
运行仅使用 1 个并行线程的 SCons。If you're using LInux, you could wrapper
gcc
org++
so that invocations of of the compiler use thegtime
utility. Every call to the compiler would look like:BASH has some magical syntax that helps you avoid having to re-escape your arguments:
Then point your $PATH variable to have your compiler wrapper.
Then run SCons with only 1 parallel thread via option
-j1
.我通过在 CXXCOM 变量的开头添加一些额外的内容来解决这个问题。 Scons 使用这个变量来进行实际的编译:
然后我使用类似的东西运行 scons
,最后使用一些 vim 宏整理日志。
I solved this by adding some extra stuff to the start of the CXXCOM variable. Scons uses this variable to do the actual compilation:
I then run scons using something like this
and finally tidy up the log using some vim macros.