HIDIHO!

giving something back to the Flash community

loops : and the winner is …

TAGS: None

yesterday still, my fellow boss (and nonetheless friend) Aurélien noticed that the ‘++’ increment operator was slower than the ‘+=1′ operator, it deserved a bench :)

… an int typed increment + a Number typed maximum in a for( int = 0; int < Number; i++ ) loop!
unbelieivable you'll say, so did I yet check the benchmarks hereunder.
default is a 10.000.000 iterations loop.

firstly, let's try to loop with an int typed maximum value:

secondly trying to loop with a uint typed max:


and finally, let’s rock and roll ; the Number typed maximum value:


you can get the sources here:

morality:

  • typing is crucial
  • for++ and a Number() typed maximum value kills them all
  • some combiantions give better results than others
  • it’s unfair but life is unfair

ok as I am not the first man on earth, here are two links to much more skilled people than me who worked on the topic (optimization):

plus of course the big chiefs ( AM, Skinner etc.)

TAGS: None

© 2009 HIDIHO!. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.