速度実験:オブジェクトをどんどん深くしていったら遅くなる?
obj.value
obj.obj.value
obj.obj.obj.value
と深くしていったら速度に差がでるのか実験
4 はやい
--------------
5 おそい
♥0 |
Line 70 |
Modified 2011-06-04 21:01:15 |
MIT License
archived:2017-03-20 10:54:57
ActionScript3 source code
/**
* Copyright lilliliililiiliililiilil ( http://wonderfl.net/user/lilliliililiiliililiilil )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/2gz2
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var textField:TextField = new TextField()
textField.text = "loading..."
textField.text = Test.check()
textField.height = 400
addChild(textField)
}
}
}
class Nest
{
public function Nest(){ value = 0.0 }
public var n:Nest
public var value:Number
}
import flash.utils.getTimer
class Test{
public static function check():String{
var result:String = "speed check \n"
,head:String = " nest :: "
,foot:String = " msec\n"
,startTime:int = 0
,n:Nest = new Nest()
,i:int = 0
,iMax:int = 10000000
n.n = new Nest()
n.n.n = new Nest()
n.n.n.n = new Nest()
n.n.n.n.n = new Nest()
n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n = new Nest()
n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n = new Nest()
result += "..0" ;startTime = getTimer(); for(i=iMax;i>0;i--){} result+=head+String(getTimer()-startTime)+foot
result += "..1" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.value} result+=head+String(getTimer()-startTime)+foot
result += "..2" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.n.value} result+=head+String(getTimer()-startTime)+foot
result += "..4" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.n.n.value} result+=head+String(getTimer()-startTime)+foot
result += "..5" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.n.n.n.value} result+=head+String(getTimer()-startTime)+foot
result += "..6" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.n.n.n.n.value} result+=head+String(getTimer()-startTime)+foot
result += "..8" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.n.n.n.n.n.n.value} result+=head+String(getTimer()-startTime)+foot
result += "10" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.n.n.n.n.n.n.n.n.n.value} result+=head+String(getTimer()-startTime)+foot
result += "12" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.n.n.n.n.n.n.n.n.n.n.n.value} result+=head+String(getTimer()-startTime)+foot
result += "14" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.n.n.n.n.n.n.n.n.n.n.n.n.n.value} result+=head+String(getTimer()-startTime)+foot
result += "16" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.value} result+=head+String(getTimer()-startTime)+foot
result += "18" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.value} result+=head+String(getTimer()-startTime)+foot
result += "20" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.value} result+=head+String(getTimer()-startTime)+foot
result += "22" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.value} result+=head+String(getTimer()-startTime)+foot
result += "24" ;startTime = getTimer(); for(i=iMax;i>0;i--){n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.value} result+=head+String(getTimer()-startTime)+foot
return result
}
}