Boost logo

Boost Users :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-07-31 14:04:13


Thomas Matelich wrote:
> So, I'm loving Foreach and as I watch it spread throughout our
> codebase, of course it runs across the desk of our optimization
> obsessed team member. So, I was curious if you could address runtime
> performance of Foreach. I would expect it to be essentially
> equivalent to a hand written for loop with caching of end(). But
> what's the overhead of the auto_any_t, etc.?

FOREACH is ~5% slower than the equivalent hand-coded loop, but for most
loops (e.g., that have non-empty loop bodies) the small overhead is lost
in the noise. What overhead there is is due to an extra test/set of a
boolean at each loop iteration.

You can find some performance comparisons here: http://tinyurl.com/2loc29

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com
The Astoria Seminar ==> http://www.astoriaseminar.com

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