Bug 449371 Firefox/Thunderbird crashes at exit [@ gdk_display_x11_finalize], p=Brian...
[wine-gecko.git] / testing / performance / talos / page_load_test / jss / real-nsieve-bits-3.html
blob9ab08d965c8c5f9c76090a5e8cb389bed5a71935
1 <html><head>
2 <!-- MOZ_INSERT_CONTENT_HOOK -->
3 <script src = runner.js></script>
4 <script>
5 var onlyName = 'N-Sieve Bits', onlyNum = 3;
6 function thisTest() {
8 // The Great Computer Language Shootout
9 // http://shootout.alioth.debian.org
11 // Contributed by Ian Osgood
13 function pad(n,width) {
14 var s = n.toString();
15 while (s.length < width) s = ' ' + s;
16 return s;
19 function primes(isPrime, n) {
20 var i, count = 0, m = 10000<<n, size = m+31>>5;
22 for (i=0; i<size; i++) isPrime[i] = 0xffffffff;
24 for (i=2; i<m; i++)
25 if (isPrime[i>>5] & 1<<(i&31)) {
26 for (var j=i+i; j<m; j+=i)
27 isPrime[j>>5] &= ~(1<<(j&31));
28 count++;
32 startTest("real-nsieve-bits");
34 for ( var i = 1; i <= 4; i++ ) (function(i){
35 test( "N-Sieve Bits", i, function(){
36 var isPrime = new Array((10000<<i)+31>>5);
37 primes(isPrime, i);
38 });
39 })(i);
41 endTest();
43 </script>
44 <body onload="thisTest()"></body></html>