cgvis the IT thing

Header Compile Time

Posted on February 4, 2010

Just coming from the Signals/Callback messup I took a short look of compiling (parsing, no instantiation) times of some C++ and Boost Headers I usually have always on.

On my machine (GCC 4.4, x86-64) without any other flags (Optimization did not seem to have a influence). I always took the user-time; no waiting for data or such things.

// Without includes: 0.04s
#include <iostream> //  0.1s
#include <string> //  0.04s
#include <vector> //  0.4s
#include <set> //  0.4s

#include <boost/shared_ptr.hpp> //  0.1s
#include <boost/signals2.hpp> //  0.8s
#include <boost/thread/mutex.hpp> //  0.3s
#include <boost/thread/recursive_mutex.hpp> //  0.3s
#include <boost/thread/thread_time.hpp> //  0.3s
#include <boost/algorithm/string.hpp> //  0.5s

// All: 1s
// All without signals2: 0.7s

// Compiling a precompiled[1] header with all: 2.5s
// Using the precompiled header: 0.13s

// Compiling a precompiled header without signals2: 1.75s
// Using the precompiled header without signals2: 0.09s

int main () { return 0; }

Important: Most includes will include other things as well, so all the boost::thread includes do include each other as well, that's why they have all the same speed.

Ok; maybe the parser of GCC is just slow; but turning off includes in order to optimize compiling speed can give you something. Magnitudes can be archived with precompiled headers. But they are a PITA, at least with cmake.

I excluded boost::asio because there is some additonal linking time on it. But it takes around 1s.

[1] Precompiled Headers: http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


Trackbacks are disabled.