js/src/devtools/jint/sunspider/math-partial-sums.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 // The Computer Language Shootout
michael@0 2 // http://shootout.alioth.debian.org/
michael@0 3 // contributed by Isaac Gouy
michael@0 4
michael@0 5 function partial(n){
michael@0 6 var a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0.0;
michael@0 7 var twothirds = 2.0/3.0;
michael@0 8 var alt = -1.0;
michael@0 9 var k2 = k3 = sk = ck = 0.0;
michael@0 10
michael@0 11 /* BEGIN LOOP */
michael@0 12 for (var k = 1; k <= n; k++){
michael@0 13 k2 = k*k;
michael@0 14 k3 = k2*k;
michael@0 15 sk = Math.sin(k);
michael@0 16 ck = Math.cos(k);
michael@0 17 alt = -alt;
michael@0 18
michael@0 19 a1 += Math.pow(twothirds,k-1);
michael@0 20 a2 += Math.pow(k,-0.5);
michael@0 21 a3 += 1.0/(k*(k+1.0));
michael@0 22 a4 += 1.0/(k3 * sk*sk);
michael@0 23 a5 += 1.0/(k3 * ck*ck);
michael@0 24 a6 += 1.0/k;
michael@0 25 a7 += 1.0/k2;
michael@0 26 a8 += alt/k;
michael@0 27 a9 += alt/(2*k -1);
michael@0 28 }
michael@0 29 /* END LOOP */
michael@0 30 }
michael@0 31
michael@0 32 /* BEGIN LOOP */
michael@0 33 for (var i = 1024; i <= 16384; i *= 2) {
michael@0 34 partial(i);
michael@0 35 }
michael@0 36 /* END LOOP */
michael@0 37

mercurial