From 07cb3389d9facb7ed8930c95199349ff35ddb1a9 Mon Sep 17 00:00:00 2001 From: mjs Date: Sat, 20 Oct 2007 23:01:19 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@26836 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- SunSpider/ChangeLog | 15 +++++ SunSpider/TODO | 2 +- SunSpider/tests/LIST | 8 ++- SunSpider/tests/access-binary-trees.js | 50 +++++++++++++++ SunSpider/tests/access-nsieve.js | 38 ++++++++++++ SunSpider/tests/bitops-nsieve-bits.js | 32 ++++++++++ SunSpider/tests/math-partial-sums.js | 33 ++++++++++ SunSpider/tests/math-spectral-norm.js | 51 ++++++++++++++++ SunSpider/tests/string-fasta.js | 85 ++++++++++++++++++++++++++ 9 files changed, 312 insertions(+), 2 deletions(-) create mode 100644 SunSpider/tests/access-binary-trees.js create mode 100644 SunSpider/tests/access-nsieve.js create mode 100644 SunSpider/tests/bitops-nsieve-bits.js create mode 100644 SunSpider/tests/math-partial-sums.js create mode 100644 SunSpider/tests/math-spectral-norm.js create mode 100644 SunSpider/tests/string-fasta.js diff --git a/SunSpider/ChangeLog b/SunSpider/ChangeLog index 2f1285c60b0f..81729bb473ff 100644 --- a/SunSpider/ChangeLog +++ b/SunSpider/ChangeLog @@ -1,3 +1,18 @@ +2007-10-20 Maciej Stachowiak + + 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 Reviewed by Darin. diff --git a/SunSpider/TODO b/SunSpider/TODO index a55c1ccc8cbe..fee4bc0fb4fb 100644 --- a/SunSpider/TODO +++ b/SunSpider/TODO @@ -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 diff --git a/SunSpider/tests/LIST b/SunSpider/tests/LIST index 9bf8ef60e086..ceaea027af07 100644 --- a/SunSpider/tests/LIST +++ b/SunSpider/tests/LIST @@ -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 index 000000000000..e2938153dfa3 --- /dev/null +++ b/SunSpider/tests/access-binary-trees.js @@ -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 index 000000000000..78b6478ad1fa --- /dev/null +++ b/SunSpider/tests/access-nsieve.js @@ -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<>5; + + for (i=0; i>5] & 1<<(i&31)) { + for (var j=i+i; j>5] &= ~(1<<(j&31)); + count++; + } +} + +function sieve() { + for (var i = 1; i <= 4; i++) { + var isPrime = new Array((10000<>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 index 000000000000..bb5378c94125 --- /dev/null +++ b/SunSpider/tests/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 <= 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 index 000000000000..f2ce57132308 --- /dev/null +++ b/SunSpider/tests/math-spectral-norm.js @@ -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; i0) { + if (n0) { + if (n