flash on 2012-3-19
...
@author ton
/**
* Copyright ton ( http://wonderfl.net/user/ton )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/fRSD
*/
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.utils.Dictionary;
import flash.utils.getTimer;
import com.actionscriptbible.Example;
/**
* ...
* @author ton
*/
public class Main extends Example
{
private static const N:int = 10000;
public function Main():void
{
trace("-----time-----");
trace("dict", recordTime(testDict));
trace("array", recordTime(testArr));
}
private function recordTime(func:Function):int
{
var time:int = getTimer();
for (var i:int = 0; i < 1000; i++) {
func();
}
return getTimer() - time;
}
private function testDict():void
{
var dict:Dictionary = new Dictionary();
for (var i:int = 0; i < N; i++) {
dict[i] = "hoge";
}
for (i = 0; i < N; i++) {
var tmp:String = dict[i];
}
}
private function testArr():void
{
var arr:Array = new Array();
for (var i:int = 0; i < N; i++) {
arr[i] = "hoge";
}
for (i = 0; i < N; i++) {
var tmp:String = arr[i];
}
}
}
}