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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial