I just tried a very similar test, but iterating just once over 200k elements, with opposite results:
Task build-arr: 2221ms
Task iter-arr: 516ms
Task build-obj: 1410ms
Task iter-obj: 953ms
I suspect Luke's test is dominated by loop overhead, which seems bigger in the array case.
Also, note that the array took significantly longer to populate in the first place, so ymmv if your task is insert-heavy.
Also, in my test, storing arr.length in a local variable gave a measurable performance increase of about 15%.
Update:
By popular demand, I am posting the code I used.
var iter:Number = 200000;
var time:Number = 0;
var obj:Object = {};
var arr:Array = [];
time = getTimer();
for (var i:Number = 0; i < iter; ++i) {
arr[i] = i;
}
trace("Task build-arr: " + (getTimer() - time) + "ms");
time = getTimer();
for (var i:Number = 0; i < iter; ++i) {
arr[i] = arr[i];
}
trace("Task iter-arr: " + (getTimer() - time) + "ms");
time = getTimer();
for (var i:Number = 0; i < iter; ++i) {
obj[String(i)] = i;
}
trace("Task build-obj: " + (getTimer() - time) + "ms");
time = getTimer();
for (var i:String in obj) {
obj[i] = obj[i];
}
trace("Task iter-obj: " + (getTimer() - time) + "ms");