Decrement versus Increment in Loop
Adobe’s “Optimizing Performance for the Flash Platform” recommends that “Use reverse order for while loops” in its “Miscellaneous optimizations” section.
while (--i > -1)
But according to my test significant difference could not be found between decrement and increment. In other language they said that decrement and increment are identical.
The pre-increment/decrement is a little faster than post, which is included in my test, though.
5 Comments
As far as I know that is true for Flash Player 10 but not Flash Player 9.
hi,
here’s what I got:
1: 1201, 1172, 1252
2: 1138, 1190,1265
3: 1103, 1175, 1276
4: 1082, 1175, 1244
5: 1077, 1153, 1243
6: 1155, 1190, 1278
7: 1108, 1200, 1276
8: 1150, 1179, 1273
config : windows 7 / FP10 / chrome / 8core-1.6Ghz / 4Go RAM
it seems that incrementation is more ’steady’ and, as you said, decrementation is not significantly faster + can even be slower.
good to know
Thank you for your reporting your result, nicoptere.
[...] order for while loops” in its “Miscellaneous optimizations” section. And in my last post, decrement was not explicitly faster than increment with the following code to compare [...]
Nice Tutorials