blog

Tag Archive for iterations at Jozef Chúťka's blog

May 19, 2010

No comments

benchmark dispatchEvent enumerations event iterations loop

A different view on loops – listener-looping

Two circular arrows crossed by a red X.

What is the usual practice when searching / setting / operating over some list of item? I think you usually think of iterating over some list (array) or linked list etc. Well, ActionScript has to offer one more technique you maybe never tought of, lets call it listener-looping. ActionScript is event based language, that means that every EventDispatcher based classes are able to listen and dispatch events. And this fits our needs for loop alternative. Lets suggest, you do not have any list to be iterated over but you still have a chance to accomplish it by making each item listening for custom event.

Read the rest of this entry »

November 11, 2009

No comments

ActionScript benchmark enumerations int iterations loops Number performance speed uint

ActionScript 3 Performance Testing

Have you ever been curious about performance (benchmark) tests in ActionScript 3? Here are some results gathered from gskinner blog.

Performance testing on loops (read more).

method............................................................. ms
for (var i:uint=0; i<length; i++)                                   40
for (var i:uint=length; i>0; i--)                                   40
var i:uint = 0; while (i < length) i++;                             40
var i:uint = length; while (--i)                                    52
var i:uint = 0; do {} while (++i < length);                         68
var i:uint = length-1; do {} while (i--);                           68
for (var b:* in arr)                                               224
for each (var b:Boolean in arr)                                    216
for each (var b:* in arr)                                          200
for each (var b:* in arr) var c:Boolean = b as Boolean;            686
arr.forEach(arrForEachF)                                          1446

Performance testing on operations with Number, int, uint. (read more)

Assignment (a:TYPE = 0) ......... min - max (ms)
int:                               24 -  45
Number:                            24 -  36
uint:                              25 -  37
Assignment (a:TYPE = 0.5) ....... min - max (ms)
int:                               56 -  83
Number:                            26 -  43
uint:                              57 -  92
Division (a:TYPE = i/2) ......... min - max (ms)
int:                               60 - 105
Number:                            34 -  64
uint:                             184 - 278
Multiplication (a:TYPE = i*2) ... min - max (ms)
int:                               78 - 129
Number:                            39 -  64
uint:                             207 - 280
Addition (a:TYPE = i+2) ......... min - max (ms)
int:                               31 -  49
Number:                            44 -  55
uint:                              85 - 113
Bitshift (a:TYPE = i<<1) ........ min - max (ms)
int:                               31 -  63
Number:                            61 - 114
uint:                              71 - 130