On 10/29/2010 5:36 PM, Ammar Ali wrote:
> I see. I excluded the i += 1 from the for and times loops because that is
> done automatically. Adding them seemed to add work that was not necessary
> for those constructs, and IMHO, make the benchmark inaccurate.

That's definitely a debatable point in this benchmark because we are
essentially doubling the number of add operations for the loops that
perform it implicitly.  However, we also want to see how the choice of
looping mechanism affects the operations performed within the loop, so
making the looped operations completely identical has its merits.

Regardless, the big thing we see is that the loops all perform roughly
equivalently overall.  Their relative differences in overhead will
likely be dwarfed by the looped operations in the real world.

In this case, I would choose the more idiomatic approach for the sake of
brevity, familiarity, and safety.  I really hate how easy it is to have
off-by-one errors and similar problems in the more manually iterated for
and while constructs.

-Jeremy