Advertisement
zwetan

test3

Oct 12th, 2011
160
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 final 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 const MAX_RATIO:Number = 1 / uint.MAX_VALUE;
  22.         public var r:uint = Math.random() * uint.MAX_VALUE;
  23.  
  24.  
  25.         public final function XORandom():Number
  26.         {
  27.             r ^= (r << 21);
  28.                 r ^= (r >>> 35);
  29.                 r ^= (r << 4);
  30.                 return (r * MAX_RATIO);
  31.         }
  32.        
  33.         public final function getTargets( s:int ):Vector.<int>
  34.         {
  35.             var t:Vector.<int> = new Vector.<int>();
  36.             var i:int;
  37.             var j:int;
  38.  
  39.             s = s<<6;
  40.             do
  41.             {
  42.                 if (controlList[s|i])
  43.                 {
  44.                     t[j++] = i;
  45.                 }
  46.             }
  47.             while(i++ < 63);
  48.            
  49.             return t;
  50.         }
  51.  
  52.         public final function loop1():void
  53.         {
  54.             for (i=0; i<4096; i++)
  55.             {
  56.                 controlList[i]   = int( XORandom() );
  57.             }
  58.         }
  59.  
  60.         public final function loop2():void
  61.         {
  62.             for (i=0; i<10000000; i++)
  63.             {
  64.                 getTargets( int( XORandom() << 6 ) );
  65.             }    
  66.         }
  67.    
  68.     }
  69.  
  70. var t2:test2 = new test2();
  71.     t2.loop1();
  72.     t2.loop2();
  73.  
  74. trace("done in", getTimer()-t2.start, "ms");
  75.  
  76.  
  77. }
  78.  
  79. /*
  80. java -jar asc.jar -AS3 -strict -import builtin.abc -import toplevel.abc test3.as
  81.  
  82. test3.abc, 893 bytes written
  83. done in 17722 ms
  84. */
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement