GUID generation stackoverflow

Benchmark created by Alber70g on


Description

Some tests after reading the stackoverflow question Create GUID / UUID in Javascript

Please read the Stackoverflow answers and comments for context

Preparation HTML

<script>
/**
 * Fast UUID generator, RFC4122 version 4 compliant.
 * @author Jeff Ward (jcward.com).
 * @license MIT license
 * @link http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
 **/
var JeffWard=function(){var e={};var t=[];for(var n=0;n<256;n++){t[n]=(n<16?"0":"")+n.toString(16)}e.generate=function(){var e=Math.random()*4294967295|0;var n=Math.random()*4294967295|0;var r=Math.random()*4294967295|0;var i=Math.random()*4294967295|0;return t[e&255]+t[e>>8&255]+t[e>>16&255]+t[e>>24&255]+"-"+t[n&255]+t[n>>8&255]+"-"+t[n>>16&15|64]+t[n>>24&255]+"-"+t[r&63|128]+t[r>>8&255]+"-"+t[r>>16&255]+t[r>>24&255]+t[i&255]+t[i>>8&255]+t[i>>16&255]+t[i>>24&255]};return e}()</script>

<script>
function Briguy37(){var e=(new Date).getTime();var t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+Math.random()*16)%16|0;e=Math.floor(e/16);return(t=="x"?n:n&3|8).toString(16)});return t}
</script>

<script>
function broofa(){ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=Math.random()*16|0,n=e=="x"?t:t&3|8;return n.toString(16)})}
</script>

Setup

var guid;

Test runner

Ready to run.

Testing in
TestOps/sec
Jeff Ward
guid = JeffWard.generate();
ready
Briguy37
guid = Briguy37();
ready
broofa
guid = broofa();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.