1 // Test the performance of Int16Array by implementing a 16-bit string hash, and
2 // test the performance of used-as-int multiplications.
4 function stringHash(array)
6 // source: http://en.wikipedia.org/wiki/Java_hashCode()#Sample_implementations_of_the_java.lang.String_algorithm
8 var len = array.length;
9 for (var index = 0; index < len; index++) {
10 h = (((31 * h) | 0) + array[index]) | 0;
15 var array = new Int16Array(1000);
16 for (var i = 0; i < array.length; ++i)
20 for (var i = 0; i < 300; ++i)
21 result += stringHash(array);
23 if (result != 168792418800)
24 throw "Bad result" + result;