//result:
//Math_sqrt is about twice as SLOW as Math.sqrt
//I am suprised.
var Math_sqrt:Function = Math.sqrt;
var loopTimes:int = 54321;
var t1:int;
var t2:int;
var tt:int;
var ii:int;
t1 = getTimer();
for(ii=0; ii < loopTimes; ii++){
Math_sqrt(ii);
}
t2 = getTimer();
tt = t2 - t1;
trace("Math_sqrt time==" + tt);
t1 = getTimer();
for(ii=0; ii < loopTimes; ii++){
Math.sqrt(ii);
}
t2 = getTimer();
tt = t2 - t1;
trace("Math.sqrt time==" + tt);
Monday, September 3, 2012
Speed Test: Binding Math Functions to variables
I was surprised!
Binding a Math library call to a function to avoid lookup using the dot
operator did not result in a performance increase. In fact, just the opposite!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment