Update ReadMe.md
[qtwebkit.git] / JSTests / microbenchmarks / Int8Array-load-with-byteLength.js
blob4c9b12287cd12402a401cd03adbe373f91b1c31e
1 // Test the performance of Int8Array by implementing Adler32.
3 function adler32(array)
5 var MOD_ADLER = 65521;
6 var a = 1;
7 var b = 0;
8 var index;
10 /* Process each byte of the data in order */
11 for (index = 0; index < array.byteLength; ++index)
13 a = (a + array[index]) % MOD_ADLER;
14 b = (b + a) % MOD_ADLER;
17 return (b << 16) | a;
20 var array = new Int8Array(1000);
21 for (var i = 0; i < array.byteLength ; ++i)
22 array[i] = i;
24 var result = 0;
25 for (var i = 0; i < 300; ++i)
26 result += adler32(array);
28 if (result != -63300)
29 throw "Bad result: " + result;