Boost logo

Boost :

Subject: Re: [boost] BOOST_FOREACH slow?
From: David Abrahams (dave_at_[hidden])
Date: 2008-11-19 18:32:28


on Wed Nov 19 2008, Eric Niebler <eric-AT-boost-consulting.com> wrote:

>> 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.

I guess not. If they care enough to find out, someone should compare
std::find with an equivalent FOREACH loop on a random access range.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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