Boost logo

Boost :

Subject: Re: [boost] BOOST_FOREACH slow?
From: Peter Bartlett (pete_at_[hidden])
Date: 2008-11-18 02:38:00


Quoting Hansi <hansipet_at_[hidden]>:

> regarding to the benchmark link posted from Michael Marcin
> BOOST_FOREACH is 3 times slower then other equivalents...it is a lot...
>
> Best regards
> Hansjörg

And that should make you sceptical of the results! Once you strip away
the TMP and macros, FOREACH is not much different from a for lopp.
There is an additional boolean [or so?] that looks ripe for
optimization. Checking that premise: I just re-ran Michael's test with
VC9 on full optimization and _SECURE_SCL=0. My results are:

Iterator accumulate took 0.235 seconds.
Pointer accumulate took 0.265 seconds.
Iterator for loop took 0.234 seconds.
Pointer for loop took 0.25 seconds.
Index for loop took 0.281 seconds.
Index for_each took 0.235 seconds.
Pointer for_each took 0.25 seconds.
BOOST_FOREACH took 0.25 seconds.
MSVC for each took 0.234 seconds.
Press any key to continue . . .


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