Boost logo

Boost :

Subject: Re: [boost] BOOST_FOREACH slow?
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2008-11-18 12:55:06


Peter Bartlett wrote:
> And that should make you sceptical of the results!

Indeed it should!

I reran the test on VC9 SP1 (the VC8 in my post was a typo it was VC9).
I got essentially identical results to my first run. I changed it from
maximize speed to full optimizations and got much better results. I
changed it to maximize speed and got similar results to full optimization.

Confused? I was. Turns out the VC9 GUI lies. If I had optimization on
inherit from project defaults it said Maximize Speed (/O2) but the /O2
switch did NOT appear on the command line. So my initial test was being
run without the /O2 switch. Thanks Microsoft.

VC9 SP1 with _SECURE_SCL=0 /O2 /Ob2 against boost trunk:

Iterator accumulate took 0.109 seconds.
Pointer accumulate took 0.11 seconds.
Iterator for loop took 0.093 seconds.
Pointer for loop took 0.094 seconds.
Index for loop took 0.094 seconds.
Iterator for_each took 0.093 seconds.
Pointer for_each took 0.094 seconds.
BOOST_FOREACH took 0.125 seconds.
MSVC for each took 0.109 seconds.
Press any key to continue . . .

VC9 SP1 with _SECURE_SCL=0 /Ox /Ob2 against boost trunk:

Iterator accumulate took 0.109 seconds.
Pointer accumulate took 0.11 seconds.
Iterator for loop took 0.109 seconds.
Pointer for loop took 0.109 seconds.
Index for loop took 0.11 seconds.
Iterator for_each took 0.109 seconds.
Pointer for_each took 0.109 seconds.
BOOST_FOREACH took 0.11 seconds.
MSVC for each took 0.109 seconds.
Press any key to continue . . .

I also corrected the "Index for_each" to read "Iterator for_each".

-- 
Michael Marcin

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