Skip to content
Browse files

uint32 benchmark

  • Loading branch information...
1 parent 07ba7ca commit 4b1d35e5f6a1d4a2e1102d11ab99bc4c450f4ab4 @kripken committed Apr 30, 2012
Showing with 21 additions and 0 deletions.
  1. +21 −0 uint32.js
View
21 uint32.js
@@ -0,0 +1,21 @@
+
+var N = 10000;
+var M = 10000;
+
+var HEAPU32 = new Uint32Array(N*2);
+
+for (var i = 0; i < N; i++) {
+ HEAPU32[i] = (i*i*i) % (N+1);
+}
+
+for (var t = 0; t < M; t++) {
+ for (var i = 0; i < N; i++) {
+ HEAPU32[N+i] = (i + HEAPU32[Math.max(i-1, 0)] + HEAPU32[Math.min(i+1, N-1)]) >>> 2; // addition that flows into >>> is still safe and in 53 bits
+ }
+ for (var i = 0; i < N; i++) {
+ HEAPU32[i] = HEAPU32[N+i];
+ }
+}
+
+//print(Array.prototype.slice.call(HEAPU32.subarray(0, N/2)));
+

0 comments on commit 4b1d35e

Please sign in to comment.
Something went wrong with that request. Please try again.