Last active
November 26, 2018 20:57
-
-
Save Kirens/bbb3d96d9fbc20d2914e97dc2ff7e775 to your computer and use it in GitHub Desktop.
Test of js engine optimization. V8 will produce machine-code of well-used functions. This unfortunately doesn't seem to run as well in Firefox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > var fTst = (v)=>((v - lomagic) & ~v & himagic)!=0; | |
| himagic = 0x80808080; | |
| lomagic = 0x01010101; | |
| var fls = [], dt = [], a = 0x500000; | |
| for(let i=0; i<20*a; i++){ | |
| if(fTst(i))fls.push(i); | |
| if(i%a==0)dt.push(+new Date); | |
| }//00000000 | |
| dt.map((v,i)=>v-dt[i-1]) | |
| > (20) [NaN, 227, 259, 166, 67, 103, 62, 57, 59, 66, 72, 60, 58, 58, 56, 54, 75, 60, 57, 59] | |
| > (20) [NaN, 184, 267, 227, 28, 19, 20, 20, 17, 17, 19, 17, 17, 17, 15, 17, 16, 17, 16, 18] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment