Accueil > as3 > AS3 Vector.sort() VS Array.sort() Benchmark

AS3 Vector.sort() VS Array.sort() Benchmark

 

Working on optimization can be fun, repetitive and mostly painful toward the end.
Here is my benchmark for the sort() function. I wanted to compare Array and Vector performances.

 

This randomizing function has been use as sorting function

test.sort(function(){return Math.floor(Math.random()*3)-1});

 

Data type

The datatype used for filling the vector/array : int

 

Loop style

1m = for(n:int=0; n<1000000; ++n) 2.5m = for(n:int=0; n<2500000; ++n)

 

Benchmark info

Each test was repeated twice
3 = length of 3
5 = length of 5
10 = length of 10
f = fixed
Both Debug Flash Player 11.1.102.55 and Flash Player 11.1.102.55 where used
Windows Quad-Core CPU

 

Conclusion

Sorting stuff with sort() function is faster within an Array than sorting stuff within a Vector.

 

 

Results in ms (1st result, 2nd result) (debug results in grey) (best result is blue)

Array3-1m = (2217,2238) - (3573,3542)
Vector3-1m = (2376,2340) - (3814,3818)
Vector3f-1m = (2361,2372) - (3791,3800)

Array3-2.5m = (5583,5550) - (9134,9186)
Vector3-2.5m = (5917,5890) - (9565,9513)
Vector3f-2.5m = (5980,5851) - (9602,9518)

 

Array5-1m = (3111,3132) - (5607,5542)
Vector5-1m = (3268,3285) - (5792,5829)
Vector5f-1m = (3266,3273) - (5788,5853)

Array5-2.5m = (7857,7951) - (14141,14166)
Vector5-2.5m = (8163,8257) - (14491,14461)
Vector5f-2.5m = (8211,8212) - (14425,14447)

 

Array10-1m = (5751,5734) - (11170,11088)
Vector10-1m = (5778,5895) - (11524,11471)
Vector10f-1m = (10525,10575) - (BUSTED)

Array10-2.5m = (14369,14242) - (BUSTED)
Vector10-2.5m = (14513,14683) - (BUSTED)
Vector10f-2.5m = (BUSTED) - (BUSTED)

  1. Pas encore de commentaire
  1. Pas encore de trackbacks
*