首页 > 匿名函数性能测试

匿名函数性能测试

第一个测试的主要代码:

private function closureTest():void{this.addEventListener(Event.ENTER_FRAME, onEnter);}private var num:int = 1000;private function onEnter(e:Event):void{for(var i:int=0; i < num; i++){var loader:URLLoader = new  URLLoader();loader.addEventListener(Event.COMPLETE, onCom);loader.removeEventListener(Event.COMPLETE, onCom);}}private function onCom(e:Event):void{trace("大妹子,吃个小龙虾聊聊人生不咯");}

结果:

 

第二个测试的主要代码:

private function closureTest():void{this.addEventListener(Event.ENTER_FRAME, onEnter);}private var num:int = 1000;private function onEnter(e:Event):void{for(var i:int=0; i < num; i++){var loader:URLLoader = new  URLLoader();loader.addEventListener(Event.COMPLETE, onCom);loader.removeEventListener(Event.COMPLETE, onCom);}function onCom(e:Event):void{trace("大妹子,吃个小龙虾聊聊人生不咯");}}

结果:

 

第三个测试的主要代码:

private var num:int = 1000;private function onEnter(e:Event):void{for(var i:int=0; i < num; i++){var loader:URLLoader = new  URLLoader();loader.addEventListener(Event.COMPLETE, function (e:Event):void{trace("大妹子,吃个小龙虾聊聊人生不咯");});}}

 结果如下:

先记下来,慢慢研究然后总结。

 

 

 

 

 

 

转载于:https://www.cnblogs.com/adoontheway/p/3219789.html

更多相关: