zwetan

test2

Oct 12th, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. package
  3. {
  4.  
  5.     import flash.utils.*;
  6.  
  7.  
  8.     public class test2
  9.     {
  10.         public var i:int;
  11.         public var start:int;
  12.         public var controlList:ByteArray;
  13.        
  14.         public function test2():void
  15.         {
  16.             start = getTimer();
  17.             controlList = new ByteArray();
  18.             controlList.length = 4096;
  19.         }
  20.        
  21.         public final function getTargets( s:int ):Vector.<int>
  22.         {
  23.             var t:Vector.<int> = new Vector.<int>();
  24.             var i:int;
  25.             var j:int;
  26.  
  27.             s = s<<6;
  28.             do
  29.             {
  30.                 if (controlList[s|i])
  31.                 {
  32.                     t[j++] = i;
  33.                 }
  34.             }
  35.             while(i++ < 63);
  36.            
  37.             return t;
  38.         }
  39.  
  40.         public final function loop1():void
  41.         {
  42.             for (i=0; i<4096; i++)
  43.             {
  44.                 controlList[i] = int(Math.round(Math.random()));
  45.             }
  46.         }
  47.  
  48.         public final function loop2():void
  49.         {
  50.             for (i=0; i<10000000; i++)
  51.             {
  52.                 getTargets(Math.floor(Math.random()*64));
  53.             }    
  54.         }
  55.    
  56.     }
  57.  
  58. var t2:test2 = new test2();
  59.     t2.loop1();
  60.     t2.loop2();
  61.  
  62. trace("done in", getTimer()-t2.start, "ms");
  63.  
  64.  
  65. }
  66.  
  67. /*
  68. java -jar asc.jar -AS3 -strict -import builtin.abc -import toplevel.abc test2.as
  69.  
  70. test2.abc, 764 bytes written
  71. done in 40200 ms
  72. */
  73.  
Advertisement
Add Comment
Please, Sign In to add comment