How to measure build time for each scons build component?

I have a big C ++ project that is created using scons. Its construction is slow, and I want to make some changes to try to make it faster. Now I would like to focus my time on speeding up those parts of the slowest build.

How can I determine which files take the longest?

+4
source share
3 answers

I solved this by adding some extra stuff to the beginning of the CXXCOM variable. Scons uses this variable to perform the actual compilation:

if os.getenv('BUILD_STYLE')=='timing': cxxcom = env['CXXCOM'] env.Replace( CXXCOM = 'time '+cxxcom ) 

Then I run scons using something like this

 BUILD_STYLE=timing scons > timing_log.txt 

and finally sort the log using some vim macros.

+2
source

I know that this question is old, and it has already been accepted, but recently it referred to another question. I think a much more elegant solution would be to use the command line SCons --debug=time , as indicated in this answer .

+3
source

If you use LInux, you can wrap gcc or g++ so that the gtime utility is used when invoking the compiler. Each compiler call will look like this:

 /usr/bin/time /usr/bin/g++ [rest of command] 

BASH has some magic syntax that helps to avoid re-eliminating your arguments:

 #!/bin/bash -f PATH_TO_COMPILER_DIR=/usr/bin /usr/bin/time $PATH_TO_COMPILER_DIR/" $@ " 

Then specify the $ PATH variable to have your own compiler shell.

Then start SCons with only one parallel thread through the -j1 option.

+2
source

All Articles