3 <script src=
"../htmlrunner.js"></script>
5 // The Great Computer Language Shootout
6 // http://shootout.alioth.debian.org
8 // Contributed by Ian Osgood
10 var last
= 42, A
= 3877, C
= 29573, M
= 139968;
13 last
= (last
* A
+ C
) % M
;
14 return max
* last
/ M
;
18 "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
19 "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" +
20 "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" +
21 "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" +
22 "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
23 "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
24 "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
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
40 function makeCumulative(table
) {
42 for (var c
in table
) {
43 if (last
) table
[c
] += table
[last
];
48 function fastaRepeat(n
, seq
) {
49 var seqi
= 0, lenOut
= 60;
51 if (n
<lenOut
) lenOut
= n
;
52 if (seqi
+ lenOut
< seq
.length
) {
53 ret
= seq
.substring(seqi
, seqi
+lenOut
);
56 var s
= seq
.substring(seqi
);
57 seqi
= lenOut
- s
.length
;
58 ret
= s
+ seq
.substring(0, seqi
);
64 function fastaRandom(n
, table
) {
65 var line
= new Array(60);
66 makeCumulative(table
);
68 if (n
<line
.length
) line
= new Array(n
);
69 for (var i
=0; i
<line
.length
; i
++) {
71 for (var c
in table
) {
83 window
.onload = function(){ startTest("sunspider-string-fasta", '8d52ecfc');
88 test( "Homo sapiens alu", function(){
89 ret
= fastaRepeat(4*n
*10000, ALU
);
92 test( "IUB ambiguity codes", function(){
93 ret
= fastaRandom(3*n
*100, IUB
);
96 test( "Homo sapiens frequency", function(){
97 ret
= fastaRandom(5*n
*100, HomoSap
);