|
Boost Users : |
Subject: Re: [Boost-users] g++ compilation is slow with Boost's constructs
From: Ilya Murav'jov (muravev_at_[hidden])
Date: 2010-09-11 18:36:58
Dave Abrahams пиÑеÑ:
> On Mon, Sep 6, 2010 at 6:23 PM, Ilya Murav'jov <muravev_at_[hidden]> wrote:
>
>> So I began to investigate and found out each invocation of known Boost
>> constructs has its non-zero cost. I chose a source file(*), commented
>> out all and then incrementally uncommented functions from beginning,
>> compiled and measured times. Here is my results (compile time, not run
>> time!):
>> - BOOST_FOREACH costs 0.1 sec
>> - boost::function<> invocation costs 0.05 sec
>> - boost::lambda::bind() with placeholders costs 0.1 sec
>> - Boost.Range adaptor transformed() costs ~0.1 too
>> As you can see, 10 boost::lambda::bind() slow down your compilation for
>> whole 1 second!
>>
>> All that is measured against gcc 4.4, Ubuntu 9.10, with the most light
>> options I picked up: "g++ -g -O0 -pipe" (I need -g for debugging
>> anyway). Also I found out that gcc 4.2 is the quickest from 4.1, 4.2,
>> 4.3, 4.4 version of gcc, and gcc 4.4 is the most slow one of them (~28%
>> slower than gcc 4.2). :(
>>
>
> G++4.5 implements O(1) template lookup, which could have a significant
> effect for Boost users.
Ok, I've done some benchmarking with g++ 4.5, g++ 4.2 and clang 1.1/llvm
2.7. Compilation time is measured with "-c -g -O0 -pipe", with Boost 1.44 .
1) 100 invocations of boost::lambda::bind(),
http://gitorious.org/bombono-dvd/bombono-dvd/blobs/master/src/mlib/tests/profile_boost_lambda.cpp
:
g++ 4.5: 9.57 sec
g++ 4.2: 14.75 sec
clang++ 1.1/llvm 2.7: 6.00 sec
MSVC2k5(OvermindDL1): 1.00 sec
2) 100 invocations of BOOST_FOREACH,
http://gitorious.org/bombono-dvd/bombono-dvd/blobs/master/src/mlib/tests/profile_boost_foreach.cpp
:
g++ 4.5: 3.15 sec
g++ 4.2: 3.95 sec
clang++ 1.1/llvm 2.7: 3.07 sec
3) 100 invocations/instantiations of boost::function,
http://gitorious.org/bombono-dvd/bombono-dvd/blobs/master/src/mlib/tests/profile_boost_function.cpp
:
g++ 4.5: 3.20 sec
g++ 4.2: 3.30 sec
clang++ 1.1/llvm 2.7: 2.74 sec
4) 100 invocations/instantiations boost::adaptors::filtered
(Boost.Range' filter on top of Boost.Iterator),
http://gitorious.org/bombono-dvd/bombono-dvd/blobs/master/src/mlib/tests/profile_boost_range.cpp
:
g++ 4.5: 4.27 sec
g++ 4.2: 6.60 sec
clang++ 1.1/llvm 2.7: 3.48 sec
Regards,
Ilya
P.S. I must admit that tests are rather synthetic but they do show the
degrees of compilers speeds.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net