Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / dromaeo / tests / sunspider-string-fasta.html
blob3f4395f70b8500b6e121e52f4a2a3074af25507e
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
10 var last = 42, A = 3877, C = 29573, M = 139968;
12 function rand(max) {
13 last = (last * A + C) % M;
14 return max * last / M;
17 var ALU =
18 "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
19 "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" +
20 "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" +
21 "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" +
22 "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
23 "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
24 "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
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
33 var HomoSap = {
34 a: 0.3029549426680,
35 c: 0.1979883004921,
36 g: 0.1975473066391,
37 t: 0.3015094502008
40 function makeCumulative(table) {
41 var last = null;
42 for (var c in table) {
43 if (last) table[c] += table[last];
44 last = c;
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);
60 n -= lenOut;
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;
78 ret = line.join('');
79 n -= line.length;
83 window.onload = function(){ startTest("sunspider-string-fasta", '8d52ecfc');
85 var ret;
86 var n = 16;
88 test( "Homo sapiens alu", function(){
89 ret = fastaRepeat(4*n*10000, ALU);
90 });
92 test( "IUB ambiguity codes", function(){
93 ret = fastaRandom(3*n*100, IUB);
94 });
96 test( "Homo sapiens frequency", function(){
97 ret = fastaRandom(5*n*100, HomoSap);
98 });
100 endTest(); };
101 </script>
102 </head>
103 <body></body>
104 </html>