1 // Copyright (c) 2004 by Arthur Langereis (arthur_ext at domain xfinitegames, tld com) 2 3 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 } 14 15 function TimeFunc(func) { 16 var x, y, t; 17 for(var x=0; x<350; x++) 18 for(var y=0; y<256; y++) func(y); 19 } 20 21 TimeFunc(bitsinbyte); 22