Boost logo

Boost :

Subject: Re: [boost] BOOST_FOREACH slow?
From: bjorn_at_[hidden]
Date: 2008-11-19 06:54:33


> Bjørn Roald wrote:
>> David Abrahams wrote:
>>> Just curious: you didn't compare with std::for_each (e.g. to see the
>>> effects of loop unrolling), did you?
>>>
> <snip>
>>
>> I got:
>> g++ -I../../boost_1_37_0 foreach_benchmark.cpp -o foreach_benchmark
> <snip>
>
> (Don't post benchmarks for unoptimized code. People who read benchmarks
> do so because they care about performance ... so they compile with
> optimizations turned on.

Well, if optimizing with the compiler affect your abillity to diagnose
problems during testing, you may end up running slow unoptimized code
during testing. So I do not agree that this is always the case. That is
why I posted both. As far as production code, I do agree it is of no
interest.

> Not only are unoptimized benchmarks
> uninteresting, they can be downright misleading if people don't realize
> what they are looking at.)

Sorry for the confusion, it was not intended.

>
>> g++ -O3 -I../../boost_1_37_0 foreach_benchmark.cpp -o
>> foreach_benchmark
>> Iterator accumulate took 0.09 seconds.
>> Pointer accumulate took 0.09 seconds.
>> Iterator for loop took 0.09 seconds.
>> Pointer for loop took 0.09 seconds.
>> Index for loop took 0.09 seconds.
>> Index for_each took 0.09 seconds.
>> Pointer for_each took 0.09 seconds.
>> BOOST_FOREACH took 0.09 seconds.
>> std::for_each took 0.09 seconds.
>
> That looks better. Thanks. So for libstdc++ at least, std::for_each is
> no faster. I just checked and it does not do loop unrolling, at least
> for 4.3.0, so that's not surprising.

Ok, do anybody know of other compilers/libs that implement loop unrolling
in std::for_each?

-- 
Bjørn

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk