Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: chrome/test/data/dromaeo/tests/sunspider-string-fasta.html

Issue 269054: Importing dromaeo performance tests to src/chrome/test/data.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script src="../htmlrunner.js"></script>
4 <script>
5 // The Great Computer Language Shootout
6 // http://shootout.alioth.debian.org
7 //
8 // Contributed by Ian Osgood
9
10 var last = 42, A = 3877, C = 29573, M = 139968;
11
12 function rand(max) {
13 last = (last * A + C) % M;
14 return max * last / M;
15 }
16
17 var ALU =
18 "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
19 "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" +
20 "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" +
21 "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" +
22 "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
23 "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
24 "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
25
26 var IUB = {
27 a:0.27, c:0.12, g:0.12, t:0.27,
28 B:0.02, D:0.02, H:0.02, K:0.02,
29 M:0.02, N:0.02, R:0.02, S:0.02,
30 V:0.02, W:0.02, Y:0.02
31 }
32
33 var HomoSap = {
34 a: 0.3029549426680,
35 c: 0.1979883004921,
36 g: 0.1975473066391,
37 t: 0.3015094502008
38 }
39
40 function makeCumulative(table) {
41 var last = null;
42 for (var c in table) {
43 if (last) table[c] += table[last];
44 last = c;
45 }
46 }
47
48 function fastaRepeat(n, seq) {
49 var seqi = 0, lenOut = 60;
50 while (n>0) {
51 if (n<lenOut) lenOut = n;
52 if (seqi + lenOut < seq.length) {
53 ret = seq.substring(seqi, seqi+lenOut);
54 seqi += lenOut;
55 } else {
56 var s = seq.substring(seqi);
57 seqi = lenOut - s.length;
58 ret = s + seq.substring(0, seqi);
59 }
60 n -= lenOut;
61 }
62 }
63
64 function fastaRandom(n, table) {
65 var line = new Array(60);
66 makeCumulative(table);
67 while (n>0) {
68 if (n<line.length) line = new Array(n);
69 for (var i=0; i<line.length; i++) {
70 var r = rand(1);
71 for (var c in table) {
72 if (r < table[c]) {
73 line[i] = c;
74 break;
75 }
76 }
77 }
78 ret = line.join('');
79 n -= line.length;
80 }
81 }
82
83 window.onload = function(){ startTest("sunspider-string-fasta", '');
84
85 var ret;
86 var n = 16;
87
88 test( "Homo sapiens alu", function(){
89 ret = fastaRepeat(4*n*10000, ALU);
90 });
91
92 test( "IUB ambiguity codes", function(){
93 ret = fastaRandom(3*n*100, IUB);
94 });
95
96 test( "Homo sapiens frequency", function(){
97 ret = fastaRandom(5*n*100, HomoSap);
98 });
99
100 endTest(); };
101 </script>
102 </head>
103 <body></body>
104 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698