mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
48 lines
950 B
HTML
48 lines
950 B
HTML
|
<html><head>
|
||
|
<!-- MOZ_INSERT_CONTENT_HOOK -->
|
||
|
<script src = runner.js></script>
|
||
|
<script>
|
||
|
var onlyName = 'Partial Sums', onlyNum = 2048;
|
||
|
function thisTest() {
|
||
|
|
||
|
// The Computer Language Shootout
|
||
|
// http://shootout.alioth.debian.org/
|
||
|
// contributed by Isaac Gouy
|
||
|
|
||
|
function partial(n){
|
||
|
var a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0.0;
|
||
|
var twothirds = 2.0/3.0;
|
||
|
var alt = -1.0;
|
||
|
var k2 = k3 = sk = ck = 0.0;
|
||
|
|
||
|
for (var k = 1; k <= n; k++){
|
||
|
k2 = k*k;
|
||
|
k3 = k2*k;
|
||
|
sk = Math.sin(k);
|
||
|
ck = Math.cos(k);
|
||
|
alt = -alt;
|
||
|
|
||
|
a1 += Math.pow(twothirds,k-1);
|
||
|
a2 += Math.pow(k,-0.5);
|
||
|
a3 += 1.0/(k*(k+1.0));
|
||
|
a4 += 1.0/(k3 * sk*sk);
|
||
|
a5 += 1.0/(k3 * ck*ck);
|
||
|
a6 += 1.0/k;
|
||
|
a7 += 1.0/k2;
|
||
|
a8 += alt/k;
|
||
|
a9 += alt/(2*k -1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
startTest("real-partial-sums");
|
||
|
|
||
|
for ( var i = 1024; i <= 8192; i *= 2 ) (function(i){
|
||
|
test( "Partial Sums", i, function(){
|
||
|
partial(i);
|
||
|
});
|
||
|
})(i);
|
||
|
|
||
|
endTest();
|
||
|
}
|
||
|
</script>
|
||
|
<body onload="thisTest()"></body></html>
|