Speed Test:
I honestly thought the vector of rectangles would be faster
because I am only accessing using an index ONCE vs FOUR times.
And I know that cutting down on that with the use of a temp
variable has helped me speed up things in the past.
For example:
Something[i].x
Something[i].y
is slower than:
temp = something[i];
temp.x
temp.y
Maybe the four vectors are faster because I am using integers?
And the rectangle type uses number type?
Anyways: I ran 3 tests:
5 vs 43 milliseconds
8 vs 68 milliseconds
4 vs 35 milliseconds
import flash.geom.Rectangle;
import flash.utils.Timer;
var t1:int;
var t2:int;
var tt:int;
var g:int;
//rectangle in vectors:
var T:Vector. = new Vector.(10);
var L:Vector. = new Vector.(10);
var B:Vector. = new Vector.(10);
var R:Vector. = new Vector.(10);
//Vs:
//Rectangle:
var VEC:Vector. = new Vector.(0);
for(var i:int = 0; i<10; i++)
{
var t:int = 1*i;
var l:int = 2*i;
var b:int = 3*i;
var r:int = 4*i;
//Make vectors:
T[i] = t;
L[i] = l;
B[i] = b;
R[i] = r;
//Make rectangle:
VEC[i] = new Rectangle(t,l,b,r);
}
var retNum:int = 12345;
var rec:Rectangle;
var n:int;
var temp:int;
t1=getTimer();
for(n=0; n
No comments:
Post a Comment