package
{
import flash.display.Sprite;
import flash.events.Event;
/**
* @author Nicolas Schudel
*/
public class Test extends Sprite
{
private var a:Array = [];
public function Test()
{
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onAddedToStage(event:Event):void
{
var i:int = 1000;
while(i--) a.push(Math.random());
trace(new PerformanceComparison(1000, testEach, testFor).start());
}
private function testEach():void
{
a.forEach(check);
}
private function testFor():void
{
var i:int = 0, n:int = a.length;
for (i = 0;i < n;i++) check(a[i]);
}
private function check(item:Number, index:int = 0, array:Array = null):void
{
item;
}
}
}