js/src/devtools/jint/sunspider/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.

     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 /* BEGIN LOOP */
     9 while(m<0x100) {
    10 if(b & m) c++;
    11 m <<= 1;
    12 }
    13 /* END LOOP */
    14 return c;
    15 }
    17 function TimeFunc(func) {
    18 var x, y, t;
    19 /* BEGIN LOOP */
    20 for(var x=0; x<350; x++) {
    21 /* BEGIN LOOP */
    22 for(var y=0; y<256; y++) func(y);
    23 /* END LOOP */
    24 }
    25 /* END LOOP */
    26 }
    28 TimeFunc(bitsinbyte);

mercurial