Last active
November 27, 2017 21:40
-
-
Save eprev/b368dc091e0fdba446845b8756efdbbc to your computer and use it in GitHub Desktop.
Revisions
-
eprev revised this gist
Nov 27, 2017 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,22 +13,22 @@ suite.add("\"use asm\";", function () { "use asm"; const N = 1000|0; let arr = new Uint32Array(N * N); for (let i = 0; (i|0) < (N|0); i=(i+1)|0) { for (let j = 0; (j|0) < (N|0); j=(j+1)|0) { arr[i * N|0 + j|0] = 1|0; } } }); suite.add("\"use asm\";", function () { "use asm"; const N = 1000|0; let arr = new Uint32Array(N * N); for (let i = 0; (i|0) < (N|0); i=(i+1)|0) { for (let j = 0; (j|0) < (N|0); j=(j+1)|0) { arr[j * N|0 + i|0] = 1|0; } } }); -
eprev revised this gist
Nov 27, 2017 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,8 @@ suite.add("\"use asm\";", function () { "use asm"; const N = 1000; let arr = new Uint32Array(N * N); for (let i = 0; i < N; i++) { @@ -21,7 +22,8 @@ } }); suite.add("\"use asm\";", function () { "use asm"; const N = 1000; let arr = new Uint32Array(N * N); for (let i = 0; i < N; i++) { -
eprev revised this gist
Nov 27, 2017 . 1 changed file with 12 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,20 +11,22 @@ suite.add("const N = 1000;", function () { const N = 1000; let arr = new Uint32Array(N * N); for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { arr[i * N + j] = 1; } } }); suite.add("const N = 1000;", function () { const N = 1000; let arr = new Uint32Array(N * N); for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { arr[j * N + i] = 1; } } }); -
eprev revised this gist
Nov 27, 2017 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,17 +11,17 @@ suite.add("let arr = new Uint32Array(1000 * 1000);", function () { let arr = new Uint32Array(1000 * 1000); for (let i = 0; i < 1000; i++) { for (let j = 0; j < 1000; j++) { arr[i * 10 + j] = 1; } } }); suite.add("let arr = new Uint32Array(1000 * 1000);", function () { let arr = new Uint32Array(1000 * 1000); for (let i = 0; i < 1000; i++) { for (let j = 0; j < 1000; j++) { arr[j * 10 + i] = 1; -
eprev revised this gist
Nov 27, 2017 . 2 changed files with 11 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ <html> <head> <meta charset="utf-8"/> <title>RAM access #jsbench #jsperf</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> <script src="./suite.js"></script> </head> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,6 +20,15 @@ } }); suite.add("var arr = new Uint32Array(1000 * 1000);", function () { var arr = new Uint32Array(1000 * 1000); for (let i = 0; i < 1000; i++) { for (let j = 0; j < 1000; j++) { arr[j * 10 + i] = 1; } } }); suite.on("cycle", function (evt) { console.log(" - " + evt.target); }); @@ -36,7 +45,7 @@ }); }); console.log("RAM access #jsbench #jsperf"); console.log(new Array(30).join("-")); suite.run(); }); -
eprev created this gist
Nov 27, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>RAM access</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> <script src="./suite.js"></script> </head> <body> <h1>Open the console to view the results</h1> <h2><code>cmd + alt + j</code> or <code>ctrl + alt + j</code></h2> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ "use strict"; (function (factory) { if (typeof Benchmark !== "undefined") { factory(Benchmark); } else { factory(require("benchmark")); } })(function (Benchmark) { var suite = new Benchmark.Suite; suite.add("var arr = new Uint32Array(1000 * 1000);", function () { var arr = new Uint32Array(1000 * 1000); for (let i = 0; i < 1000; i++) { for (let j = 0; j < 1000; j++) { arr[i * 10 + j] = 1; } } }); suite.on("cycle", function (evt) { console.log(" - " + evt.target); }); suite.on("complete", function (evt) { console.log(new Array(30).join("-")); var results = evt.currentTarget.sort(function (a, b) { return b.hz - a.hz; }); results.forEach(function (item) { console.log((idx + 1) + ". " + item); }); }); console.log("RAM access"); console.log(new Array(30).join("-")); suite.run(); });