js/src/jit-test/tests/sunspider/check-bitops-bits-in-byte.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 // Copyright (c) 2004 by Arthur Langereis (arthur_ext at domain xfinitegames, tld com)
     4 // 1 op = 2 assigns, 16 compare/branches, 8 ANDs, (0-8) ADDs, 8 SHLs
     5 // O(n)
     6 function bitsinbyte(b) {
     7 var m = 1, c = 0;
     8 while(m<0x100) {
     9 if(b & m) c++;
    10 m <<= 1;
    11 }
    12 return c;
    13 }
    15 var ret = 0;
    16 function TimeFunc(func) {
    17 var x, y, t;
    18 for(var x=0; x<350; x++)
    19 for(var y=0; y<256; y++) 
    20   ret += func(y);
    21 }
    23 TimeFunc(bitsinbyte);
    24 assertEq(ret, 358400)

mercurial