-
-
Save icebob/940eea0410f245cb9d3b11d3bd0d4cb1 to your computer and use it in GitHub Desktop.
Revisions
-
icebob revised this gist
Jan 10, 2017 . 1 changed file with 0 additions and 20 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 @@ -22,26 +22,6 @@ }); }); suite.add("const d0 = Math.random()*0xffffffff|0;", function () { const d0 = Math.random()*0xffffffff|0; const d1 = Math.random()*0xffffffff|0; -
icebob revised this gist
Jan 10, 2017 . No changes.There are no files selected for viewing
-
icebob revised this gist
Jan 10, 2017 . 1 changed file with 15 additions and 0 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 @@ -9,6 +9,10 @@ })(function (Benchmark) { var suite = new Benchmark.Suite; Benchmark.prototype.setup = function () { const lut = []; for (let i=0; i<256; i++) { lut[i] = (i<16?'0':'')+(i).toString(16); } }; suite.add("'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {", function () { @@ -38,6 +42,17 @@ }); }); suite.add("const d0 = Math.random()*0xffffffff|0;", function () { const d0 = Math.random()*0xffffffff|0; const d1 = Math.random()*0xffffffff|0; const d2 = Math.random()*0xffffffff|0; const d3 = Math.random()*0xffffffff|0; return lut[d0&0xff]+lut[d0>>8&0xff]+lut[d0>>16&0xff]+lut[d0>>24&0xff]+'-'+ lut[d1&0xff]+lut[d1>>8&0xff]+'-'+lut[d1>>16&0x0f|0x40]+lut[d1>>24&0xff]+'-'+ lut[d2&0x3f|0x80]+lut[d2>>8&0xff]+'-'+lut[d2>>16&0xff]+lut[d2>>24&0xff]+ lut[d3&0xff]+lut[d3>>8&0xff]+lut[d3>>16&0xff]+lut[d3>>24&0xff]; }); suite.on("cycle", function (evt) { console.log(" - " + evt.target); }); -
gobwas created this gist
Dec 23, 2015 .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>UUID</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,60 @@ "use strict"; (function (factory) { if (typeof Benchmark !== "undefined") { factory(Benchmark); } else { factory(require("benchmark")); } })(function (Benchmark) { var suite = new Benchmark.Suite; suite.add("'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {", function () { 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); return v.toString(16); }); }); suite.add("function random(min, max) {", function () { function random(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/(x{1,8}|y)/g, function(c) { var r, v; var n = c.length; if (n == 1) { r = Math.random()*16|0; v = c == 'x' ? r : (r&0x3|0x8); } else { v = random(1<<(4*(n-1)), (1<<(4*n)) - 1) } return v.toString(16); }); }); 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("UUID"); console.log(new Array(30).join("-")); suite.run(); });