Wed, 18 May 2005

Compile times with C++

As everyone knows, I'm a huge Wesnoth fan. I found an interview with the lead developer from last year on PCTechTalk where he complained about compile times with g++.

So I downloaded the CVS and did some testing, and sent him the results. Most of these are probably fairly obvious to people, but the figures are interesting:

  1. Raw build time
    make clean; time make > /tmp/out
    487.80user 26.41system 8:59.65elapsed
  2. Build time without -O2
    make clean; time make CXXFLAGS=-g > /tmp/out
    193.98user 14.84system 4:00.92elapsed
  3. Built time without -O2, one file touched
    touch src/global.hpp; time make CXXFLAGS=-g > /tmp/out
    191.53user 9.52system 3:43.92elapsed
  4. Build time with ccache installed, one file touched:
    touch src/global.hpp; time make CXXFLAGS=-g > /tmp/out"
    10.45user 2.04system 0:37.46elapsed
  5. Built time with ccache, one file touched, output to screen:
    touch src/global.hpp; /usr/bin/time make CXXFLAGS=-g"
    10.73user 2.06system 0:47.85elapsed

Summary: don't use -O when developing, use ccache, use distcc. If you're still not fast enough you can try suppressing all screen output (probably not worth the pain of not seeing what's happening), or using pre-compiled headers (in recent gcc versions).

[/tech] permanent link