Reviewed by Mark.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 20 Oct 2007 23:01:19 +0000 (23:01 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 20 Oct 2007 23:01:19 +0000 (23:01 +0000)
        - Add more new tests, mostly from the computer language shootout. Not normalized yet.

        * TODO:
        * tests/LIST:
        * tests/access-binary-trees.js: Added.
        * tests/access-nsieve.js: Added.
        * tests/bitops-nsieve-bits.js: Added.
        * tests/math-partial-sums.js: Added.
        * tests/math-spectral-norm.js: Added.
        * tests/string-fasta.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@26836 268f45cc-cd09-0410-ab3c-d52691b4dbfc

SunSpider/ChangeLog
SunSpider/TODO
SunSpider/tests/LIST
SunSpider/tests/access-binary-trees.js [new file with mode: 0644]
SunSpider/tests/access-nsieve.js [new file with mode: 0644]
SunSpider/tests/bitops-nsieve-bits.js [new file with mode: 0644]
SunSpider/tests/math-partial-sums.js [new file with mode: 0644]
SunSpider/tests/math-spectral-norm.js [new file with mode: 0644]
SunSpider/tests/string-fasta.js [new file with mode: 0644]

index 2f1285c..81729bb 100644 (file)
@@ -1,5 +1,20 @@
 2007-10-20  Maciej Stachowiak  <mjs@apple.com>
 
+        Reviewed by Mark.
+
+        - Add more new tests, mostly from the computer language shootout. Not normalized yet.
+        
+        * TODO:
+        * tests/LIST:
+        * tests/access-binary-trees.js: Added.
+        * tests/access-nsieve.js: Added.
+        * tests/bitops-nsieve-bits.js: Added.
+        * tests/math-partial-sums.js: Added.
+        * tests/math-spectral-norm.js: Added.
+        * tests/string-fasta.js: Added.
+
+2007-10-20  Maciej Stachowiak  <mjs@apple.com>
+
         Reviewed by Darin.
 
         * TODO: Updated to note areas that are now well-covered.
index a55c1cc..fee4bc0 100644 (file)
@@ -4,7 +4,7 @@
 
   (X marks the ones that are fairly well covered now).
 
-    - math (general)
+    X math (general)
     X bitops
     X 3-d (the math bits)
     - crypto / encoding
index 9bf8ef6..ceaea02 100644 (file)
@@ -1,10 +1,16 @@
 3d-cube
 3d-morph
 3d-raytrace
+access-binary-trees
+access-nsieve
 bitops-3bit-bits-in-byte
 bitops-bits-in-byte
 bitops-bitwise-and
+bitops-nsieve-bits
 math-cordic
+math-partial-sums
+math-spectral-norm
 string-base64
+string-fasta
 string-tagcloud
-string-unpack-code
+string-unpack-code
\ No newline at end of file
diff --git a/SunSpider/tests/access-binary-trees.js b/SunSpider/tests/access-binary-trees.js
new file mode 100644 (file)
index 0000000..e293815
--- /dev/null
@@ -0,0 +1,50 @@
+/* The Great Computer Language Shootout
+   http://shootout.alioth.debian.org/
+   contributed by Isaac Gouy */
+
+function TreeNode(left,right,item){
+   this.left = left;
+   this.right = right;
+   this.item = item;
+}
+
+TreeNode.prototype.itemCheck = function(){
+   if (this.left==null) return this.item;
+   else return this.item + this.left.itemCheck() - this.right.itemCheck();
+}
+
+function bottomUpTree(item,depth){
+   if (depth>0){
+      return new TreeNode(
+          bottomUpTree(2*item-1, depth-1)
+         ,bottomUpTree(2*item, depth-1)
+         ,item
+      );
+   }
+   else {
+      return new TreeNode(null,null,item);
+   }
+}
+
+var ret;
+
+for ( var n = 2; n <= 8; n *= 2 ) {
+    var minDepth = 4;
+    var maxDepth = Math.max(minDepth + 2, n);
+    var stretchDepth = maxDepth + 1;
+    
+    var check = bottomUpTree(0,stretchDepth).itemCheck();
+    
+    var longLivedTree = bottomUpTree(0,maxDepth);
+    for (var depth=minDepth; depth<=maxDepth; depth+=2){
+        var iterations = 1 << (maxDepth - depth + minDepth);
+
+        check = 0;
+        for (var i=1; i<=iterations; i++){
+            check += bottomUpTree(i,depth).itemCheck();
+            check += bottomUpTree(-i,depth).itemCheck();
+        }
+    }
+
+    ret = longLivedTree.itemCheck();
+}
diff --git a/SunSpider/tests/access-nsieve.js b/SunSpider/tests/access-nsieve.js
new file mode 100644 (file)
index 0000000..78b6478
--- /dev/null
@@ -0,0 +1,38 @@
+// The Great Computer Language Shootout
+// http://shootout.alioth.debian.org/
+//
+// modified by Isaac Gouy
+
+function pad(number,width){
+   var s = number.toString();
+   var prefixWidth = width - s.length;
+   if (prefixWidth>0){
+      for (var i=1; i<=prefixWidth; i++) s = " " + s;
+   }
+   return s;
+}
+
+function nsieve(m, isPrime){
+   var i, k, count;
+
+   for (i=2; i<=m; i++) { isPrime[i] = true; }
+   count = 0;
+
+   for (i=2; i<=m; i++){
+      if (isPrime[i]) {
+         for (k=i+i; k<=m; k+=i) isPrime[k] = false;
+         count++;
+      }
+   }
+   return count;
+}
+
+function sieve() {
+    for (var i = 1; i <= 4; i++ ) {
+        var m = (1<<i)*10000;
+        var flags = Array(m+1);
+        nsieve(m, flags);
+    }
+}
+
+sieve();
\ No newline at end of file
diff --git a/SunSpider/tests/bitops-nsieve-bits.js b/SunSpider/tests/bitops-nsieve-bits.js
new file mode 100644 (file)
index 0000000..b8e7db6
--- /dev/null
@@ -0,0 +1,32 @@
+// The Great Computer Language Shootout
+//  http://shootout.alioth.debian.org
+//
+//  Contributed by Ian Osgood
+
+function pad(n,width) {
+  var s = n.toString();
+  while (s.length < width) s = ' ' + s;
+  return s;
+}
+
+function primes(isPrime, n) {
+  var i, count = 0, m = 10000<<n, size = m+31>>5;
+
+  for (i=0; i<size; i++) isPrime[i] = 0xffffffff;
+
+  for (i=2; i<m; i++)
+    if (isPrime[i>>5] & 1<<(i&31)) {
+      for (var j=i+i; j<m; j+=i)
+        isPrime[j>>5] &= ~(1<<(j&31));
+      count++;
+    }
+}
+
+function sieve() {
+    for (var i = 1; i <= 4; i++) {
+        var isPrime = new Array((10000<<i)+31>>5);
+        primes(isPrime, i);
+    }
+}
+
+sieve();
diff --git a/SunSpider/tests/math-partial-sums.js b/SunSpider/tests/math-partial-sums.js
new file mode 100644 (file)
index 0000000..bb5378c
--- /dev/null
@@ -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 <= 8192; i *= 2) {
+    partial(i);
+}
+
diff --git a/SunSpider/tests/math-spectral-norm.js b/SunSpider/tests/math-spectral-norm.js
new file mode 100644 (file)
index 0000000..f2ce571
--- /dev/null
@@ -0,0 +1,51 @@
+// The Great Computer Language Shootout
+// http://shootout.alioth.debian.org/
+//
+// contributed by Ian Osgood
+
+function A(i,j) {
+  return 1/((i+j)*(i+j+1)/2+i+1);
+}
+
+function Au(u,v) {
+  for (var i=0; i<u.length; ++i) {
+    var t = 0;
+    for (var j=0; j<u.length; ++j)
+      t += A(i,j) * u[j];
+    v[i] = t;
+  }
+}
+
+function Atu(u,v) {
+  for (var i=0; i<u.length; ++i) {
+    var t = 0;
+    for (var j=0; j<u.length; ++j)
+      t += A(j,i) * u[j];
+    v[i] = t;
+  }
+}
+
+function AtAu(u,v,w) {
+  Au(u,w);
+  Atu(w,v);
+}
+
+function spectralnorm(n) {
+  var i, u=[], v=[], w=[], vv=0, vBv=0;
+  for (i=0; i<n; ++i) {
+    u[i] = 1; v[i] = w[i] = 0;
+  }
+  for (i=0; i<10; ++i) {
+    AtAu(u,v,w);
+    AtAu(v,u,w);
+  }
+  for (i=0; i<n; ++i) {
+    vBv += u[i]*v[i];
+    vv  += v[i]*v[i];
+  }
+  return Math.sqrt(vBv/vv);
+}
+
+for (var i = 8; i <= 64; i *= 2) {
+    spectralnorm(i);
+}
diff --git a/SunSpider/tests/string-fasta.js b/SunSpider/tests/string-fasta.js
new file mode 100644 (file)
index 0000000..ae96ebd
--- /dev/null
@@ -0,0 +1,85 @@
+// The Great Computer Language Shootout
+//  http://shootout.alioth.debian.org
+//
+//  Contributed by Ian Osgood
+
+var last = 42, A = 3877, C = 29573, M = 139968;
+
+function rand(max) {
+  last = (last * A + C) % M;
+  return max * last / M;
+}
+
+var ALU =
+  "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
+  "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" +
+  "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" +
+  "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" +
+  "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
+  "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
+  "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
+
+var IUB = {
+  a:0.27, c:0.12, g:0.12, t:0.27,
+  B:0.02, D:0.02, H:0.02, K:0.02,
+  M:0.02, N:0.02, R:0.02, S:0.02,
+  V:0.02, W:0.02, Y:0.02
+}
+
+var HomoSap = {
+  a: 0.3029549426680,
+  c: 0.1979883004921,
+  g: 0.1975473066391,
+  t: 0.3015094502008
+}
+
+function makeCumulative(table) {
+  var last = null;
+  for (var c in table) {
+    if (last) table[c] += table[last];
+    last = c;
+  }
+}
+
+function fastaRepeat(n, seq) {
+  var seqi = 0, lenOut = 60;
+  while (n>0) {
+    if (n<lenOut) lenOut = n;
+    if (seqi + lenOut < seq.length) {
+      ret = seq.substring(seqi, seqi+lenOut);
+      seqi += lenOut;
+    } else {
+      var s = seq.substring(seqi);
+      seqi = lenOut - s.length;
+      ret = s + seq.substring(0, seqi);
+    }
+    n -= lenOut;
+  }
+}
+
+function fastaRandom(n, table) {
+  var line = new Array(60);
+  makeCumulative(table);
+  while (n>0) {
+    if (n<line.length) line = new Array(n);
+    for (var i=0; i<line.length; i++) {
+      var r = rand(1);
+      for (var c in table) {
+        if (r < table[c]) {
+          line[i] = c;
+          break;
+        }
+      }
+    }
+    ret = line.join('');
+    n -= line.length;
+  }
+}
+
+var ret;
+
+for (var n = 2; n <= 16; n *= 2) {
+    ret = fastaRepeat(2*n*100000, ALU);
+    ret = fastaRandom(3*n*1000, IUB);
+    ret = fastaRandom(5*n*1000, HomoSap);
+}