summaryrefslogtreecommitdiffstats
path: root/PerformanceTests/SunSpider/tests/sunspider-0.9.1/math-partial-sums.js
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-06 11:45:16 +0100
committerSteve Block <steveblock@google.com>2011-05-12 13:44:10 +0100
commitcad810f21b803229eb11403f9209855525a25d57 (patch)
tree29a6fd0279be608e0fe9ffe9841f722f0f4e4269 /PerformanceTests/SunSpider/tests/sunspider-0.9.1/math-partial-sums.js
parent121b0cf4517156d0ac5111caf9830c51b69bae8f (diff)
downloadexternal_webkit-cad810f21b803229eb11403f9209855525a25d57.zip
external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.gz
external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.bz2
Merge WebKit at r75315: Initial merge by git.
Change-Id: I570314b346ce101c935ed22a626b48c2af266b84
Diffstat (limited to 'PerformanceTests/SunSpider/tests/sunspider-0.9.1/math-partial-sums.js')
-rw-r--r--PerformanceTests/SunSpider/tests/sunspider-0.9.1/math-partial-sums.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/PerformanceTests/SunSpider/tests/sunspider-0.9.1/math-partial-sums.js b/PerformanceTests/SunSpider/tests/sunspider-0.9.1/math-partial-sums.js
new file mode 100644
index 0000000..d082d79
--- /dev/null
+++ b/PerformanceTests/SunSpider/tests/sunspider-0.9.1/math-partial-sums.js
@@ -0,0 +1,33 @@
+// 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);
+ }
+}
+
+for (var i = 1024; i <= 16384; i *= 2) {
+ partial(i);
+}
+