Hok's Macromedia Flash Blog

macromedia flash actionscript scripting, php, remoting, webservices, c#, javascript

Ads

Search

Performance: fastest while-loop for traversing an array

There was a discussion on flashcoders-mailinglist what the
fastest while-loop is. The result is interessting, it shows the
speed-difference between the minus- and plus-operator
and post- and pre-increment-operator. It seems that the
postincrement ist slower because it have to store the new value
until the rest of the expression is evaluated. c = 40000;t = getTimer();l = c;while (l--);trace(getTimer() - t);t = getTimer();l = c;while (--l+1);trace(getTimer() - t);t = getTimer();l = c;while (--l-(-1));trace(getTimer() - t);// output:// 744// 549// 545

Posted by hOk at April 5, 2003 05:11 PM

Comments (1)

i believe that do {
} while (--1-(-1))

is the fastest fastest

Posted by dan at March 24, 2004 11:53 AM


Name:


Email Address:


URL:


Comments:



You can use <code>code that should be highlightned</code> to highlight code!
Optionally you can use the attribut language="php|perl|java" within the code tag, otherwise
actionscript-highlightning will be used.

New Place