Search code examples
sconstiming

How can I measure the build time for each component of a scons build?


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?


Solution

  • I solved this by adding some extra stuff to the start of the CXXCOM variable. Scons uses this variable to do the actual compilation:

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

    I then run scons using something like this

    BUILD_STYLE=timing scons > timing_log.txt
    

    and finally tidy up the log using some vim macros.