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):
- http://blog.je2050.de/2008/04/26/actionscript-3-optimization-techniques/
- http://lab.polygonal.de/2007/05/10/bitwise-gems-fast-integer-math/
plus of course the big chiefs ( AM, Skinner etc.)
my beloved readers wrote…